var array = [[4,'dasd'],[5,'dasd'],[1,'dasd'],[2,'dasd'],[3,'dasd'],[13,'dasd'],[23,'dasd']]
var newarray = []
array.map(i => {
let index = newarray.findIndex((j) => j[0] > i[0])
index === -1 ? newarray.push(i) : newarray.splice(index, 0, i)
});
console.log(newarray)
发表评论
fuck
回复 @kcuf: hehe
kcuf
回复 @fuck: 可以啊
fuck
hao
MrTreasure
我也分享一个
```js
let arr = [[4,'dasd'],[5,'dasd'],[1,'dasd'],[2,'dasd'],[3,'dasd'],[13,'dasd'],[23,'dasd']];
let arrB = [];
arrB = arr.sort((a,b) => {
return a[0]>b[0];
});
console.log(arrB);
```
这个空间复杂度要低点吧