通过sort方法对数组对象进行排序
let checkList = [
{
"serial_number": 60,
"status": 1001,
},
{
"serial_number": 80,
"status": 1001,
},
{
"serial_number": 10,
"status": 1001,
},
{
"serial_number": 70,
"status": 1001,
}
]
function sortAsc(property) {
return function (a, b) {
const val1 = a[property];
const val2 = b[property];
return val1 - val2;
}
}
checkList.sort(sortAsc('serial_number'));