Is there any way to get the Nth key or value of an ordered hash other than converting it to an array?

Viewed 7100

In Ruby 1.9.x I have a hash that maintains its order

hsh = {9=>2, 8=>3, 5=>2, 4=>2, 2=>1}

Is there a way to get say the key of the third element other than this:

hsh.to_a[2][0]
2 Answers
Related