<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> JavaScript Array sorting instance _ webpage code site (www.webdm.cn) </title>
<SCRIPT type = "text/JavaScript">
S = [
{First: 'job', last: 'awk '},
{First: 'zwe', last: 'oli '},
{First: 'job', last: 'asp '}
];
For (VAR I = 0; I <S. length; I ++ ){
Document. Write (s [I]. First + "+ s [I]. Last +" <br/> ");
}
Document. Write ("<HR/> ")
S. Sort (function (a, B ){
VaR result = A. First. localecompare (B. First );
If (result = 0)
Result = A. Last. localecompare (B. Last );
Return result;
})
For (VAR I = 0; I <S. length; I ++ ){
Document. Write (s [I]. First + "+ s [I]. Last +" <br/> ");
}
</SCRIPT>
</Head>
<Body>
<Br/>
<P> <a href = "http://www.webdm.cn"> Web code site </A>-the most professional web code download site-is committed to providing quality web code for Chinese webmasters! </P>
</Body>
</Html>
Reprinted from: http://www.webdm.cn/webcode/02ca308a-d531-469b-9c2d-d4b311ef3b58.html