Rather than burdening every comparison of the sort with a conditional test, it'll be more efficient to sort the keys to an array and then reverse the array conditionally:
my @sorted = sort { $scores{$b} <=> $scores{$a} } keys %scores; @sorted = reverse @sorted if condition; for ( @sorted ) { ... }
In reply to Re: Store operation in a variable
by BrowserUk
in thread Store operation in a variable
by vit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |