From: Daniel Lucraft Date: 2007-07-08T18:49:52+09:00 Subject: Re: simple array question Shai Rosenfeld wrote: > is there a nice clean method to do the following: > # i want to take the 'array' var and make it into seperate arrays > according to the att1 attribute, i.e, resulting in the example above to > I keep 'group_by' (stolen from ActiveSupport) on me for just such situations: module Enumerable def group_by inject({}) do |groups, element| (groups[yield(element)] ||= []) << element groups end end end array.group_by {|el| el.att1} best, Dan -- Posted via http://www.ruby-forum.com/.