From: Harry Kakueki Date: 2009-10-02T00:04:22+09:00 Subject: Re: how do you do this On Thu, Oct 1, 2009 at 9:23 PM, George George wrote: > Given an array of strings e.g. > x = ["abc","abcde" "def","xyzwj"] and of different lengths, > how can you efficiently create new arrays of strings which are of the > same length. for example the above array can be transformed into > > x1 = ["abc","def"] > x2 = ["abcde","xyzwj"] > > Thank you. > p x.map{|a| a.length}.uniq.map{|b| x.select{|c| c.length == b}} #> [["abc", "def"], ["abcde", "xyzwj"]] Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html