Forum: Ruby Re: Sorting with Hash

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Kroeger, Simon (ext) (Guest)
on 2006-04-27 17:10
(Received via mailing list)
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 topic is locked and can not be replied to.