Re: Excel Type Sorting ???
- From: tom@xxxxxxxxxxxxxx (Tom Phoenix)
- Date: Sat, 16 Feb 2008 08:05:06 -0800
On Feb 15, 2008 1:36 PM, <ezsuperkev@xxxxxxxxx> wrote:
I'm trying to figure out how to do an Excel type sort in Perl but
can't seem to find anything on specifically what I want to do. So here
goes.
I think you want to sort on multiple criteria, with nothing "Excel" about it.
Imagine 3 columns of numbers: A, B, C.
I want to sort in descending order starting with Column A then Column
B, and then Column C.
Thing is I don't want the order of A to change when sorting B and i
don't want the order of A or B to change when sorting C.
So you sort on criterion A. When that's a tie, you go on to use
criterion B, then finally C. That's just a single sort operation,
using a sort sub something like this:
sub sort_by_ABC {
$a->{A} cmp $b->{A} or
$a->{B} cmp $b->{B} or
$a->{C} cmp $b->{C}
}
Of course, that's probably not the way your criteria are stored, but
it should give you the general idea.
http://perldoc.perl.org/functions/sort.html
Good luck with it!
--Tom Phoenix
Stonehenge Perl Training
.
- References:
- Excel Type Sorting ???
- From: ezsuperkev
- Excel Type Sorting ???
- Prev by Date: Re: Printing text between two blank lines
- Next by Date: Re: Excel Type Sorting ???
- Previous by thread: Excel Type Sorting ???
- Next by thread: Re: Excel Type Sorting ???
- Index(es):
Relevant Pages
|