Sorting with Hash


#1

Hi all,

I have a hash like this and i want to sort. After sorting i want the key
and value seperately. like say

c=Hash.new
h = { “c” => 20, “b” => 30, “a” => 10 }

c = h.sort
puts c
====>which will result in
a
10
b
30
c
20

puts c[0]
===>which will result in
a
10

Now after we have sorted i want to fetch the individual key/value like
we know ‘a’ is the key and 10 is the value above. How can we get them
individually (key/value after we sort) any methods are there ? pl help
me out…

We are storing the sorted result in another hash c.

Can we get the individual key/value pairs from this c. (which is sorted)
??

Or is there any other other way to do ?

Thank You.
Dinesh