From: Jeff Peng Date: 2010-01-06T19:17:40+09:00 Subject: Re: group in the array Kolya17 Kolya17: > > I'm trying to get another two-dimensional array, which would be the > grouping of the first elements. > In SQL it would be so: > Hi, You could use a hash for translating that. x= [["200912-829", 9],["200912-893", 3],["200912-893", 5],["200912-829", 1],["200911-818", 6],["200911-893", 1],["200911-827", 2]] hash = Hash.new(0) x.each do |c| hash[c[0]] += c[1] end new = hash.to_a p new