2006/1/30, Jonathan Leighton <lists / turnipspatch.com>:
> On Mon, 2006-01-30 at 05:33 +0900, Simon Kr÷šer 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.

What exactly do you want to do?  Can you describe it other than in
code? Input, output etc.

Cheers

robert

--
Have a look: http://www.flickr.com/photos/fussel-foto/