按照对象的值大小排序对象 function sortObj(obj) { var arr = []; for (var i in obj) { arr.push([obj[i],i]); }; arr.sort(function (a,b) { return a[0] - b[0]; }); var len = arr.length, obj = {}; for (var i = 0; i < len; i++) { obj[arr[i][1]] = arr[i][0]; } return ob…
const b = [{index:5,name:"s5"}, {index:2,name:"s2"}, {index:3,name:"s3"}, {index:1,name:"s1"}, {index:8,name:"s8"}]; var a = [], i; for (var i = 0; i < b.length; i++) { var num = b[i].index; a[num] = a[…