Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var array = [2,1,5,4,8,99,3,7];
- var arrlength = array.length;
- for(var i = 0; i < arrlength; i++) {
- pos = i
- valor = array[i]
- while(pos > 0 && valor < array[pos - 1]){
- array[pos] = array[pos - 1]
- pos = pos - 1
- }
- array[pos] = valor
- }
- console.log(array)
Add Comment
Please, Sign In to add comment