const ASS = new Array(20).fill(20).map((v, i) => {
return Math.floor(Math.random()*50)
})
console.log("ASS",ASS)
const ABB = (data:Array<number>) =>{
let A:Array<number> =[]
for(let i = 0; i < data.length; i++){
if(A.length < 1) {
A.push(data[i])
}else{
for(let k = 0; k < A.length; k++) {
if(data[i] <= A[k]) {
A.splice(k, 0, data[i])
break
}
if(k == A.length - 1) {
A.push(data[i])
}
}
}
}
return A
}
let A = ABB(ASS)
console.log(A)
简单的数字排序
最新推荐文章于 2024-08-18 07:29:32 发布