K
kenlo888
Hi,
I have data in an array like:
(1,'black'), (2,'black'), (1,'orange'), (2,'brown'), (1,'green')
I want to sort the first column, then the second column. Very similar
to a sql order by statement "order by row1, row2".
The desired output would be:
(1,'black'), (1,'green'), (1,'orange'), (2,'black),(2,'brown')
I understand how to use the sort function in perl...
@sorted_Array=sort{$a->[$sort_row]cmp$b->[$sort_row]}@array;
but this can only sort one set of rows. If you have any examples of
multiple row sorts, that would be great.
Thanks.
-Ken
I have data in an array like:
(1,'black'), (2,'black'), (1,'orange'), (2,'brown'), (1,'green')
I want to sort the first column, then the second column. Very similar
to a sql order by statement "order by row1, row2".
The desired output would be:
(1,'black'), (1,'green'), (1,'orange'), (2,'black),(2,'brown')
I understand how to use the sort function in perl...
@sorted_Array=sort{$a->[$sort_row]cmp$b->[$sort_row]}@array;
but this can only sort one set of rows. If you have any examples of
multiple row sorts, that would be great.
Thanks.
-Ken