Created
August 3, 2018 20:50
-
-
Save idealwebsolutions/0532c587bec6a61f215e861af641286c to your computer and use it in GitHub Desktop.
(Old) Selection sort
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
function selectionSort(array) { | |
for (var i = 0; i < array.length - 1; i++) { | |
for (var j = i + 1; j < array.length; j++) { | |
if (array[i] > array[j]) { | |
var temp = array[i]; | |
array[i] = array[j]; | |
array[j] = temp; | |
} | |
} | |
} | |
return array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment