On Feb 15, 2008 1:36 PM, <[EMAIL PROTECTED]> 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
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/