数组按照其中某一项比较大小排序

function compare(property) {
           return function (a, b) {
             var value1 = a[property]
             var value2 = b[property]
             return value1 - value2
           }
         }
         console.log(data.sort(compare('searchDay')))

你可能感兴趣的:(javascript)