let arr=[1,4,32,41,7,13]; for(let i=0;i<arr.length-1;i++){ for(let j=0;j<arr.length-1;j++){ if(arr[i]>arr[i+1]){ [arr[i],arr[i+1]]=[arr[i+1],arr[i]] } } } console.log(arr)