in reply to Re: sort direction
in thread sort direction

How about dispatching the direction to get the appropriate sort function?
my %sorts = ( DESC => sub { $hash{$b}{$orderby} <=> $hash{$a}{$orderby} or $hash{$b}{$orderby} cmp $hash{$a}{$orderby} }, ASC => sub { $hash{$a}{$orderby} <=> $hash{$b}{$orderby} or $hash{$a}{$orderby} cmp $hash{$b}{$orderby} } ); my $sort_func = $sorts{$direction}; foreach my $id (sort { &$sort_func } keys %hash) {
Update: do the hash lookup only once, not for every comparison.

Caution: Contents may have been coded under pressure.