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) { #... }
In reply to Re: sort direction
by Tanktalus
in thread sort direction
by rsiedl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |