桶排序-Node.js-对象排序

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[num]||{};
a[num] = b[i];
num == null;
} for (var i = 0; i < a.length; i++) {
if(a[i]) console.log(a[i].name);
}
上一篇:Ocelot中文文档-不支持


下一篇:向 Web 开发人员推荐35款 JavaScript 图形图表库