数组排序固定写法

var arr=[1,40,20,10,100];

arr.sort(function(a,b){

if(a>b){

return 1;

}else if(a==b){

return 0;

}else{

return -1;

}

});

console.log(arr);

原文地址:https://www.cnblogs.com/Yanss/p/10285558.html