Skip to content

Instantly share code, notes, and snippets.

@renaehodgkins
Created November 23, 2008 03:58
Show Gist options
  • Save renaehodgkins/28025 to your computer and use it in GitHub Desktop.
Save renaehodgkins/28025 to your computer and use it in GitHub Desktop.
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