Created
November 23, 2008 03:58
-
-
Save renaehodgkins/28025 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
def insertion_sort(words) | |
words.each_with_index do |word, index| | |
index.downto(0) do |placement| | |
if (placement > 0 && word < words[placement-1]) | |
words[placement] = words[placement-1] | |
else | |
words[placement] = word | |
break | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment