On Thu, Oct 1, 2009 at 1:23 PM, George George <george.githinji / gmail.com> wrote:
> Given an array of strings e.g.
>   ۢ㢬 梬  
> how can you efficiently create new arrays of strings which are of the
> same length. for example the above array can be transformed into

Well, here's something close:

h = {}
x.each do |i|
  h[i.length] ||= []
  h[i.length] << i
end

h is now a hash: {3=>["abc", "def"], 5=>["abcde", "xyzwj"]}

That's close enough to what you want that I'm sure you can run with
it.  Look in the "Group by unique entries of a hash" thread for more
ideas.
>
> x1 = ["abc","def"]
> x2 = ["abcde","xyzwj"]
>
> Thank you.
> --
> Posted via http://www.ruby-forum.com/.
>
>



-- 
Paul Smith
http://www.nomadicfun.co.uk

paul / pollyandpaul.co.uk