From: Jeremy Bopp Date: 2010-09-24T00:27:45+09:00 Subject: Re: Sorting problem with an Array of Arrays On 9/22/2010 11:30 PM, Paul wrote: > Hi Jeremy, thanks for the reply. > > On Sep 22, 6:54 pm, Jeremy Bopp wrote: > >>> You could define a class to represent each of your inner array elements. >>> That class could then define the <=> method in which you could compare >>> each item in the order you desire. Then your outer array, consisting of >>> instances of your class, could be trivially sorted with Array#sort. > > I'm afraid I don't understand what you are saying here. All I > understood was "could be trivially sorted with Array#sort." I don't > understand classes. Classes are rather a central concept in Ruby, so it would be a really good idea to learn about them; however, they are not necessary here. I'll keep this short and say that using an array of arrays such as what you have here can make your code cryptic and brittle as it grows and ages. Using a class to represent your inner array items will help avoid these issues. :-) I see that you have more details about your problem in a later reply, so I'll see about addressing more issues there. -Jeremy