my @keys = sort { $hash{$a} cmp $hash{$b} } keys %hash;
See also sort for how to construct a custom sorting function. Note that since some of your values are duplicates, a sort is not guaranteed stable, i.e. you can get different results from subsequent executions. If this matters, you can add an extra term to your sort so it sorts first by value then by a guaranteed unique quantity, the key:
my @keys = sort { $hash{$a} cmp $hash{$b} or $a cmp $b} keys %hash;
In reply to Re: Sort Hash Values Alphabetically
by kennethk
in thread Sort Hash Values Alphabetically
by danj35
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |