Created
February 17, 2014 08:27
-
-
Save richard-to/9046834 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(list) { | |
var value = 0; | |
var pos = 0; | |
for (var i = 1; i < list.length; ++i) { | |
value = list[i]; | |
pos = i - 1; | |
while (pos >= 0 && value < list[pos]) { | |
list[pos + 1] = list[pos]; | |
--pos; | |
} | |
list[pos + 1] = value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment