关于数组排序sort(a,b)里两个参数的问题?
<script type="text/javascript">
function sortNum(a,b) {
return a - b;
//升序,如降序,把“a - b”该成“b - a”
}
var myarr = new Array("80","16","50","6","100","1");
document.write(myarr + "<br>");
document.write(myarr.sort(sortNum));
</script>
就上面这个案例来说,a,b是只指数组里前面两个数字吗,a-b只要看前面两个数字相减大于0还是小于0,然后决定整个数组的排序顺序吗?