Last active
May 10, 2019 20:12
-
-
Save SafaElmali/043fdd115901200867202456759fc90d to your computer and use it in GitHub Desktop.
Sorting Algorithm
This file contains hidden or 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
//Sorting Algorithm | |
function sortArray(arr) { | |
let temp; | |
for (let i = 0; i < arr.length; i++) { | |
if (arr[i] > arr[i + 1]) { | |
temp = arr[i]; | |
arr[i] = arr[i + 1]; | |
arr[i + 1] = temp; | |
console.log(arr); | |
return sortArray(arr); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment