前端常用业务逻辑处理
1.利用sort对一个对象数组按照对象某个属性进行排序
sort方法有两个注意点:会操作原始数组,经过操作后原始数组发生变化;默认排序按照字符编码排序。
var sdts = [ {name:"小明",age:12}, {name:"小红",age:13}, {name:"小花",age:11} ]
sdts.sort(sortBy("score")); // [{name:"小花",age:11},{name:"小明",age:12}, {name:"小红",age:13}]
可参考https://www.cnblogs.com/webcabana/p/7460038.html