1.soft排序法
var arr=[2,3,55,33,11,1];
function getSoft(a,b){
if(a>b){
return 1
}else if(a<b){
return -1
}else{
return 0
}
};
a.sort(getSoft)
console.log(a)
//简洁方法
var arr=[2,3,55,33,11,1];
function getSoft(a,b){
return a-b
};
a.sort(getSoft)
console.log(a)