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);
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