Traditionally, hashes are not ordered and therefore not sorted. Ruby 1.9 hashes are ordered, but the language does not provide an easy way to reorder items. As in 1.8, hash sorting returns an array of pairs:
{ c:3, a:1, b:2 }.sort => [ [:a,1], [:b,2], [:c,3] ]
(Actually, 1.8 would blow it up, because the characters are not comparable in 1.8, but it doesn't matter).
, ( ) . sort_by , , , :
foo.sort_by { |key, strings| strings.join.length }
, , :
foo.sort_by { |key, strings| -strings.join.length }
, 1.9 , (, Jörg W Mittag):
Hash[ foo.sort_by { |key, strings| strings.join.length } ]
..., , d11wtq.