in reply to sort direction
Interestingly, no one suggested using different sort functions.
(untested)sub mysort_asc { $hash{$a}{$orderby} <=> $hash{$b}{$orderby} || $hash{$a}{$orderby} cmp $hash{$b}{$orderby} } sub mysort_desc { $hash{$b}{$orderby} <=> $hash{$a}{$orderby} || $hash{$b}{$orderby} cmp $hash{$a}{$orderby} } my $sort_func = $direction eq 'DESC' ? \&mysort_desc : \&mysort_asc; foreach my $id (sort { &$sort_func } keys %hash) { #... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sort direction
by Roy Johnson (Monsignor) on Oct 07, 2005 at 15:36 UTC |