Last active
May 13, 2019 11:24
-
-
Save negarjf/e20595fc8c6b4f0ae713f633c70e8b7f to your computer and use it in GitHub Desktop.
JS Bin// source https://jsbin.com/hosocabisi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let testArray = [10, 25, 25, 12, 22, 11, 90]; | |
console.log(sort(testArray)); | |
function sort(array){ | |
let length = array.length; | |
for(let i = 0; i < length; i++ ){ | |
let j = 0; | |
while(j < length - i - 1 ){ | |
if(array[j] > array[j + 1]){ | |
let temp = array[j]; | |
array[j] = array[j + 1]; | |
array[j + 1] = temp; | |
} | |
j++; | |
} | |
} | |
return array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment