https://segmentfault.com/a/1190000000410506
var arr = [1,55,33,44,11,99,10,44]; // 降序 console.info(arr.sort(function(a, b) { return b - a; })); // 升序 console.info(arr.sort(function(a, b) { return a - b; })); // 升序 arr2 = [{sort: 21},{sort: 12},{sort: 33},{sort: 14},{sort: 55}]; console.info(arr2.sort(function(a, b) { return a.sort - b.sort; }));
欢迎加入,Java,前端的共同学习【爱问共享编程部落】 479668591