From: Ryan Davis Date: 2009-03-20T11:44:20+09:00 Subject: Re: Complex sort of matrix possible, e.g. like Excel? On Mar 17, 2009, at 22:02 , RichardOnRails wrote: > I've got an array of rows (and thus a matrix) created user FasterCSV > to extract data from a CSV file. I'd like to sort the matrix on > column A ascending and, within that, column B descending. I looked at > Matrix, but it doesn't seem to address that functionality. Is there > a package that does, or do I have to write my own SuperMatrix > inherited from Matrix? I'm kinda surprised nobody has said this: sorted = matrix.sort_by { |row| [row[0], -row[1]] } P.S. PLEASE trim to the relevant parts when you reply. In some of your email on this thread you have two whole copies of nearly the whole thread.