let sort = [12,6,3,88,1,4,8] for(let i=0; isort[i]){ //swaping elements let temp = sort[i]; sort[i]=sort[j]; sort[j]= temp; } } } console.log(sort)