Created
April 24, 2016 20:52
-
-
Save galenweber/98115fe7cf8c50d93d130e2438d15d5b 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
var insertionSort = function(array) { | |
var temp; | |
for (var i = 1; i < array.length; i++) { | |
temp = i; | |
for (var x = i-1; x >= 0 && array[x] > i; x-- ) { | |
array[x+1] = array[x]; | |
} | |
array[x+1] = temp; | |
console.log("array is: ", array) | |
} | |
return array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment