Last active
April 24, 2016 20:52
-
-
Save galenweber/9d75f47bf1ab27d86d0ff8303d5769f0 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++) { | |
for (var x = 0; x < i; x++ ) { | |
if (array[i] < array[x]) { | |
temp = array[i]; | |
for (var z = i; z > x; z--) { | |
array[z] = array[z-1]; | |
} | |
array[x] = temp; | |
} | |
} | |
} | |
return array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment