更新时间:2022-04-04 22:39:03
var a = [
["tag_17", 0, 4],
["tag_18", 13, 18],
["tag_435", 6, 11]
];
a.sort(sortFunction);
console.log(a);
function sortFunction(a, b) {
if (a[0] === b[0]) {
return 0;
}
return (a[1] < b[1]) ? 1 : -1;
}
您可以阅读有关 sort 的文档. a>.
You can read the documentation about sort.