数值排序:
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); 标签:sort,arr,return,name,compare,排序 From: https://www.cnblogs.com/ljbkyBlog/p/17584035.html