irb(main):001:0> aers = %w(a b c d ab bc de abc) #=> ["a", "b", "c", "d", "ab", "bc", "de", "abc"] irb(main):002:0> aers.group_by{ |s| s.size } #=> {1=>["a", "b", "c", "d"], 2=>["ab", "bc", "de"], 3=>["abc"]} people.group_by { |p| p['age'] }