RichardOnRails
3/18/2009 2:23:00 PM
On Mar 18, 1:58 am, Christopher Dicely <cmdic...@gmail.com> wrote:
> Enumerable#sort lets you do this fairly easily with just a pure array
> of arrays, e.g., to sort the array-of-arrays "arr" by the first column
> ascending and the second descending:
>
> arr.sort {|a,b| [a[0]<=>b[0], b[1]<=>a[1]].find {|x| x!=0} || 0}
>
> On 3/17/09, RichardOnRails <RichardDummyMailbox58...@uscomputergurus.com> wrote:
>
> > Hi,
>
> > 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?
>
> > Thanks in Advance,
> > Richard
>
>
Hey Christopher,
That's perfect! I had faith that the community had dealt with this
issue.
Best wishes,
Richard