Created
April 23, 2019 08:15
-
-
Save 4skinSkywalker/736e66056f401ddd1029872511300724 to your computer and use it in GitHub Desktop.
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(array) { | |
| for (var i = 0; i < array.length - 1; i++) { | |
| let vMin = array[i] | |
| let iMin = i | |
| for (var j = i + 1; j < array.length; j++) { | |
| if (vMin > array[j]) { | |
| vMin = array[j] | |
| iMin = j | |
| } | |
| } | |
| [array[i], array[iMin]] = [array[iMin], array[i]] | |
| } | |
| return array | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment