And you probably want to use 'cmp' instead of '<=>'. '<=>' is for numerical comparison, 'cmp' is for strings. See perlop.my @sorted_keys_by_value = sort { $unsorted_hash{$a} cmp $unsorted_hash{$b} } keys %unsorted_hash;
In reply to Re: Want to sort hashes by values, anyone?
by runrig
in thread Want to sort hashes by values, anyone?
by Doraemon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |