I'm still learning Perl, so there's probably a more efficient way of doing this. I'm trying to take a hash, reverse it so $values => $keys, grab the new key (the old value) and then sort those keys.
Here's the code in question:
foreach my $key (sort keys reverse %hash){
...}
What I'm expecting to happen is that reverse %hash will return a hash type, which is what keys is looking for. However, I get the following error:
Type of arg 1 to keys must be hash (not reverse)
I've tried putting parentheses around reverse %hash, but still get the same thing.
Any ideas why this wouldn't work?