From: "Peña, Botp" Date: 2008-07-03T13:53:55+09:00 Subject: Re: thoughts on a more generic Array#partition function From: Rudi Cilibrasi [mailto:cilibrar@gmail.com] # h = 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, > h=a.group_by { |i| i % 3 } => {0=>[3, 9, 12], 1=>[1, 4, 7, 13], 2=>[2, 11, 14]} > h.values => [[3, 9, 12], [1, 4, 7, 13], [2, 11, 14]] kind regards -botp