Created
August 8, 2023 22:48
-
-
Save koalicioous/732f2fa07c11be013e1f3a3965eefbe2 to your computer and use it in GitHub Desktop.
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
const selectionSort = (arr: number[]) => { | |
for (let i = 0; i < arr.length; i++) { | |
let minIndex = i | |
for (let j = i; j < arr.length; j++) { | |
if (arr[j] < arr[i]) minIndex = j | |
} | |
[arr[i], arr[minIndex]] = [arr[minIndex], arr[i]] | |
} | |
return arr | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment