Skip to content

Instantly share code, notes, and snippets.

@negarjf
Last active May 13, 2019 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save negarjf/e20595fc8c6b4f0ae713f633c70e8b7f to your computer and use it in GitHub Desktop.
Save negarjf/e20595fc8c6b4f0ae713f633c70e8b7f to your computer and use it in GitHub Desktop.
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