[ {:name=>'fred', :age=>32}, {:name=>'barney', :age=>42}, ].group_by { |person| person[:name] } => {"fred"=>[{:name=>"fred", :age=>32}], "barney"=>[{:name=>"barney", :age=>42}]}
Array-shaped keys have the ability to have multiple Freds or Barneys, but you can use .map to restore if you really need to.
source share