From: "Jesús Gabriel y Galán" Date: 2009-10-02T00:42:11+09:00 Subject: Re: how do you do this On Thu, Oct 1, 2009 at 5:20 PM, David A. Black wrote: > Hi -- > > On Thu, 1 Oct 2009, Jesús Gabriel y Galán wrote: >> %w{abc ads adfdf adfdw fefm mfekmw fmdms}.group_by {|x| x.length} > > It's interesting how often the need for group_by without the keys > comes up. Meaning, in this case, to get the new arrays you'd > ultimately do: > >  arr.group_by(&:length).values Yup, although in this case, I'm going to guess that he will either - Access the list of words of a specific number desired_length = something a = %w{abc ads adfdf adfdw fefm mfekmw fmdms}.group_by {|x| x.length} a[desired_length] - Sort the groups by length a = %w{abc ads adfdf adfdw fefm mfekmw fmdms}.group_by {|x| x.length} a.sort.map {|x| x[1]} # or something > and I believe there was at least one similar case mentioned here > recently. I wonder whether it would be cool to have a method that did > this -- in effect: > >  module Enumerable >    def group_by_without_keys(&block) >      group_by(&block).values >    end >  end > > I'm not sure what it should be called, though. values_grouped_by ? Jesus.