You almost had it. You need to wrap the sort in {} and the hash in parenthsis.
foreach (sort {$hash{$a} cmp $hash{$b}} (keys %hash)
In reply to Re: sort hash by value
by sulfericacid
in thread sort hash by value
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |