慕容8154426
2017-10-02 10:13
<script type="text/javascript">
function sortNum(a,b) {
return b-a;//这里写成b-a,与-1,有什么区别吗?
}
var myarr = new Array("80","16","50","6","100","1");
document.write(myarr.sort(sortNum));
a-b是升序,b-a是降序
JavaScript进阶篇
468060 学习 · 21891 问题
相似问题