let arr = ['-5,6,7,4,2,3','5,9,10,11,15,12','0,1,14,8,13,18']
function sss(){
let newArr = []
for(let i=0;i<arr.length;i++){
newArr = newArr.concat(arr[i].split(','))
}
for(let j =0;j<newArr.length;j++){
newArr[j] = parseInt(newArr[j]);
}
return newArr
}
async function ArrSort(){
let ab = await sss()
for(let j=0;j<ab.length;j++){
for(let i=0;i<ab.length-1-j;i++){
if(ab[i] > ab[i+1]){
let tem = ab[i+1]
ab[i+1] = ab[i]
ab[i] = tem
}
}
}
console.log(ab)
}
ArrSort()
自定义排序方法
于 2023-02-27 20:56:03 首次发布