对象数组按 key 进行排序

对象数组按 key 进行排序

let sortBy = function(keyName,method){
    return function(a,b) {
        if(method == 'up') return b[keyName] - a[keyName]
        else if(method == 'down') return a[keyName] - b[keyName];
    }
}
Comments
Write a Comment