substitute <=> with cmp for string sort instead of numeric sort.for my $key (sort { $hash{$b} <=> $hash{$a} } keys %hash) { print $hash{$key}; }
In reply to Re: algorithm question: want to sort keys of hash by their values.
by Joost
in thread algorithm question: want to sort keys of hash by their values.
by downer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |