Created
January 3, 2021 11:42
-
-
Save darkcris1/6a2a122ae33070c8705e93b809d7161b to your computer and use it in GitHub Desktop.
Selection Sort 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
function selectionSort(arr) { | |
for (let i = 0; i < arr.length; i++) { | |
for (let j = 0; j < arr.length; j++) { | |
if (arr[i] < arr[j]) { | |
const temp = arr[i] | |
arr[i] = arr[j] | |
arr[j] = temp | |
} | |
} | |
} | |
return arr | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment