const newArr = [
{
index: 199
},
{
index: 14
},
{
index: 55
},
{
index: 201
},
{
index: 68
}]
newArr.sort(function (a, b) {
return a.index - b.index
})
console.log(newArr);
// 打印值:[{index: 14},{index: 55},{index: 68},{index: 199},{index: 201}]
sort函数中数组排序
最新推荐文章于 2024-07-27 21:14:19 发布