From: "Simon Kröger" Date: 2006-01-31T06:27:09+09:00 Subject: Re: Loop weirdness > > I did, back in the thread a little: Sorry, missed that. > But don't worry about it, I am happy with the solution I've found. (That > is, there is no longer a *problem*, although I'm always interested to > see better/leaner/cleaner ways of doing things). :) another try: def categorise(items) items.inject([]) do |a, item| ary = a.assoc(item[:num]) || (a << [item[:num], []]).last ary.last << item[:foo]; a end.map{|k, v| {:num => k, :items => v}} end cheers Simon