From: Josselin Date: 2007-03-28T00:50:04+09:00 Subject: Re: splitting an array into sub_arrays ...need advice On 2007-03-25 22:28:42 +0200, Olivier Renaud said: > Note that partition_by is a simple method with no dependencies. So, you can > just copy/paste this method in your code from facets.rubyforge.org online > documentation. Here it is : > > module Enumerable > def partition_by > r = Hash.new{ |h,k| h[k]=[] } > each do |e| > r[ yield(e) ] << e > end > return r > end > end > > And then : > > require 'enumerator' > start_array.partition_by {|ary| ary[1..2]}.to_enum(:each_value).to_a thanks a lot I got it