Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment