let arr = [10,50,20,40,30]
for(let i = 0;i<arr.length-1;i++){
for(let j=0;j<arr.length-1-i;j++){
if(arr[j]>arr[j+1]){
const temp = arr[j+1]
arr[j+1] = arr[j]
arr[j] = temp
}
}
}
console.log(arr)
2.用sort
let arr = [10,50,20,40,30,111,12,234]
arr.sort((a,b)=>{return a-b})
console.log(arr)