数组里面为对象根据某一属性排序

compare(par,desc){
        return function(a,b){
    var value1 = a[par];
    var value2 = b[par];
        if(desc == true){ 
return value1 - value2
}else{return value2-value1} } }

 

posted @ 2021-11-18 14:33  web格调  阅读(28)  评论(0编辑  收藏  举报