let arr =[9,3,4,2,5,7,6,8,1]
let b=''
for(let i =0;i<arr.leaght;i++){
for(let j =0;j<arr.leaght-i;j++){
if(arr[j]>arr[j+1]){
b=arr[j]
arr[j]=arr[j+1]
arr[j+1]=b
}
}
}
console.log(arr)
//[1,2,3,4,5,6,7,8,9]
02-25
1857
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-08
2117
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-06