方法一:利用数组的entries方法进行排序
function sortArr(arr) {
var goNext = true;
var entries = arr.entries();
while (goNext) {
var result = entries.next();
if (result.done !== true) {
result.value[1].sort((a, b) => a - b);
goNext = true;
} else {
goNext = false;
}
}
return arr;
}
var arr = [[1,2],[4,122,3,222],[4567,1,4,5,6],[34,78,23,1]];
sortArr(arr);
网友评论