From: Brian Mitchell Date: 2006-10-14T07:42:47+09:00 Subject: Re: Sorting through an array of an array On 10/13/06, Dominic Son wrote: > Hello. > > Each of my arrays look like this: > container[0] = ["foo", "bar", "baz"] > container[1] = ["doo", "poo", "woo"] > > i'd like to sort by the second position (bar, and poo) > and of course,affecting the whole row, so that "bar" should be on top, > along with "foo" and "baz" as container[0]. > > What method should i use? Actually, the better way to sort in this scenario is to use sort_by. container.sort_by {|x| x[1]} No need to mess with the <=> operator by hand. Brian.