js对象数组排序
对象数组排序
const arr = [
{name: '参数1', sort: 1},
{name: '参数3', sort: 3},
{name: '参数2', sort: 2},
];
arr.sort((a, b) => a.sort - b.sort);
console.log(arr);
// 结果如下:
// {name: '参数1', sort: 1},
// {name: '参数2', sort: 2},
// {name: '参数3', sort: 3},
参考自:https://blog.csdn.net/z93701081/article/details/90239188

浙公网安备 33010602011771号