var i =0; var j =0; while(i<list.length){ j=-1; while(j<i){ j++; if(list[i]<list[j]){ var temp = list[i]; list[i]=list[j]; list[j]= temp; } } i++; }