How to sort an array of strings.
# Sort array of strings. Strings can be enclosed by
# single or double quotes.
puts ['foo', 'bar', "apple", "jack"].sort
puts "\nNow let's sort in descending order.\n\n"
# This time we'll use an easier way to make an array of words.
puts %w(foo bar apple jack).sort{ |a,b| b<=>a }
puts "\nSorted on last character of each word:\n\n"
puts %w(foo bar apple jack).sort_by{ |x| x[-1] }