# Re: Sorting with Hash

**URL:** <https://www.ruby-forum.com/t/re-sorting-with-hash/94276>\
**Category:** Ruby\
**Created:** [April 27, 2006, 3:23pm UTC](https://www.ruby-forum.com/t/re-sorting-with-hash/94276 "2006-04-27T15:23:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KroegerS\_Simon\_Sext](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/57b2e6/32.png) [@KroegerS\_Simon\_Sext](https://www.ruby-forum.com/u/KroegerS_Simon_Sext)\
**Post date:** [April 27, 2006, 3:23pm UTC](https://www.ruby-forum.com/t/re-sorting-with-hash/94276/1 "2006-04-27T15:23:25Z")

</div>

Sorry, after reading your post again I guess I haven’t  
understand your problem.

Standard Hashes are not sorted, never. If you call  
sort on a Hash you get nested arrays.

[[“a”, 10], [“b”, 30], [“c”, 20]]

if you want to iterate over this array just use each.

c.each{|k, v| do\_something(k, v)}

if you want the value corresponding to a key use assoc.

c.assoc(‘b’) #=\> 30

(but this is slow on large arrays)

Hth

Simon
