除了支持普通数组的排序,还要支持数组对象的排序。
从小到大: [1,3,2,5] ==> [1,2,3,5] 按年龄从小到大: [{name:’b’,age:12},{name:’c’,age:21},{name:’a’,age:2}] ==> [{name:’a’,age:2},{name:’b’,age:12},{name:’c’,age:21},]
underscore 和 async 虽然都有sortby() 函数支持,但还是不太好用。
7 回复
除了支持普通数组的排序,还要支持数组对象的排序。
从小到大: [1,3,2,5] ==> [1,2,3,5] 按年龄从小到大: [{name:’b’,age:12},{name:’c’,age:21},{name:’a’,age:2}] ==> [{name:’a’,age:2},{name:’b’,age:12},{name:’c’,age:21},]
underscore 和 async 虽然都有sortby() 函数支持,但还是不太好用。