On Mon, 2006-01-30 at 05:33 +0900, Simon Kröger wrote: > Jonathan Leighton wrote: > > > Hi, > > > > I'm going ever so slightly crazy over some looping behaviour. Here's a > > simplified test case I made: > > Is this what you are trying to do? > > def categorise(items) > items.inject(Hash.new([])) do |h, item| > h[item[:num]] += [item[:foo]]; h > end.map{|k, v| {:num => k, :items => v}} > end That's cool (although crowded), but it doesn't fit the bill for me as I need the order to be retained. Thanks anyway Jon -- Jonathan Leighton http://turnipspatch.com/ | http://jonathanleighton.com/ | http://digital-proof.org/