Re: Sorting with Hash

Hi Dinesh!

h = { “c” => 20, “b” => 30, “a” => 10 }
c = h.keys.sort.map{|k| [k, h[k]]}

puts c
puts ‘=======’
puts c[0]

cheers

Simon

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs