<div class="codetitle"> <span><a style="CURSOR: pointer" data="86243" class="copybut" id="copybut86243" onclick="doCopy('code86243')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code86243"> <br><title>JavaScript对文字按照拼音排序</title><br><SCRIPT type="text/javascript"><br>function defaultSort(){<br>var a="zhongguo,daguo,世界,中国,超级大国";<br>a=a.split(",");<br>a.sort();<br>alert(a);<br>}<br>function cusSort(){<br>var a="zhongguo,daguo,世界,中国,超级大国";<br>a=a.split(",");<br>a.sort(function(a,b){<br> return a.localeCompare(b);<br>});<br>alert(a);<br>}<br></SCRIPT><br><a href="#" onClick="defaultSort();">默认排序</a><br><br><a href="#" onClick="cusSort();">按拼音字母排序</a> <br> </div>