I have an array of hashes, something like
[ {:type=>\"Meat\", :name=>\"one\"}, {:type=>\"Meat\", :name=>\"two\"}, {:type=>\"Fruit\", :n
I would do as below :
hsh =[{:type=>"Meat", :name=>"one"}, {:type=>"Meat", :name=>"two"}, {:type=>"Fruit", :name=>"four"}] p Hash[hsh.group_by{|h| h[:type] }.map{|k,v| [k,v.map{|h|h[:name]}]}] # >> {"Meat"=>["one", "two"], "Fruit"=>["four"]}