sort进行排序
var arr = [100,50,90,30,80]; function sortNum (a,b){ console.log(a); console.log(b); return a-b } console.log(arr.sort(sortNum));
a-b 是升序
b-a是降序
sort进行排序
var arr = [100,50,90,30,80]; function sortNum (a,b){ console.log(a); console.log(b); return a-b } console.log(arr.sort(sortNum));
a-b 是升序
b-a是降序