求js对象键名根据键值排序,按排序顺序产生新键名数组的高效算法_百度知 ...答:function(a, b){ return data[b]-data[a];});console.log(keys);[ '1002', '1003', '1004', '1001', '1005' ]只是js对象的健是字符串,用的时候还要转换一下 const out=keys.map(function(x){return parseInt(x);});console.log(out);[ 1002, 1003, 1004, 1001, 1005 ]