2021-10-01

ES6 数组对象排序

let data = [ {value: 335, name: '家电'}, {value: 310, name: '服装'}, {value: 274, name: '食品'}, {value: 235, name: '数码'}, {value: 400, name: '家纺'} ]data.sort(function (a, b) { return a.value - b.value; })

你可能感兴趣的:(2021-10-01)