hash sort ruby code example
Example: sort hash ruby
people = {
:fred => 23,
:joan => 18,
:pete => 54
}
# First option
people.values.sort # => [18, 23, 54]
# Seconf option
people.sort_by { |name, age| age }
# => [[:joan, 18], [:fred, 23], [:pete, 54]]