From: Jean-Julien Fleck Date: 2010-04-03T15:08:26+09:00 Subject: Re: hash key with multiple values Hello, > i have the hash result is I would rather say that it is an array of hashes that you want to transform into an hash of arrays. > Please help me First, you have to get the keys that will be in the resulting hash, for example using inject (that here merge all the hashes into one big hashes but loosing multiple entries of the same key): arr = [{x=>"i8"}, {y=>"i58"}, {y=>"i6"}, {y=>"v5"}, {z=>"ci5"}, {z=>"i63"}, {w=>"cie201"}] keys = arr.inject {|hash,h| hash.merge(h)}.keys p keys Then iterate over the keys and populate the resulting hash by selecting all the adequate values (that is those whose call don't answer nil) and collecting them: result_hash = {} keys.each do |k| result_hash[k] = arr.select {|h| h[k]}.collect {|h| h[k]} end p result_hash Hope this helps. -- JJ Fleck PCSI1 Lycée Kléber