let arr = [1,25,21,44,32,556,443]; for(let i = 0;i<arr.length;i++){ for(let j = 0;j<arr.length-i-1;j++){ let temp; if(arr[j]>arr[j+1]){ temp = arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } console.log(arr); // console.log(arr.sort());