sort排序
数值排序:
arr.sort((a,b)=>a.id - b.id);
字符串排序:
var compare = function (a, b) {
if (a.name< b.name) {
return -1;
} else if (a.name > b.name) {
return 1;
} else {
return 0;
}
}
arr.sort(compare);