Skip to content

Instantly share code, notes, and snippets.

@KristineHines
Created April 1, 2013 23:55
Show Gist options
  • Save KristineHines/5288799 to your computer and use it in GitHub Desktop.
Save KristineHines/5288799 to your computer and use it in GitHub Desktop.
def dictionary_sort
puts "Type a word!"
word = gets.chomp
unsorted = []
until word == ""
unsorted << word
word = gets.chomp
end
puts "Congratulations! Your dictionary has #{unsorted.length} words:"
sorted_array = unsorted.sort {|a, b| a.downcase <=> b.downcase}
puts sorted_array
end
dictionary_sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment