From: Rick DeNatale Date: 2008-07-03T20:40:51+09:00 Subject: Re: thoughts on a more generic Array#partition function ------=_Part_6530_15572337.1215085260286 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thu, Jul 3, 2008 at 12:53 AM, Pe=F1a, Botp wrot= e: > From: Rudi Cilibrasi [mailto:cilibrar@gmail.com] > # h =3D a.group_by() { |i| func(i) } > # h.keys.sort.map { |k| h[k] } > # This is not so bad, but perhaps has a small disadvantage that it > # requires eql? and hash methods defined unlike npartition. But I > # cannot figure out a simpler version to get array of array's output. > > just apply #values to it, > Not exactly the same, values doesn't guarantee the desired ordering by key. Ruby 1.9 orders hashes by insertion history, Ruby < 1.8.7 doesn't order the= m at all, not sure about 1.8.7 --=20 Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ ------=_Part_6530_15572337.1215085260286--