sort排序

原文链接https://www.jianshu.com/p/6968f71ed5df
var objs = [
{name: ‘B’, num: 9},
{name: ‘C’, num: 2},
{name: ‘D’, num: 4},
{name: ‘B’, num: 5},
{name: ‘C’, num: 9},
{name: ‘E’, num: 6},
{name: ‘F’, num: 4},
{name: ‘F’, num: 12}
];
objs.sort((star,next)=>{
// return star.num - next.num
return next.num - star.num
})

上一篇:Werkzeug之LocalStack源码解析


下一篇:GitHub 公布 2021 Top 10 博文「GitHub 热点速览」