Is this is the correct and best way to sort an hash by values so I can get the keys according to that ? do you know any other way to do this task. efficient way always welcome
my %hash = (value1 => 345, value2 => 132, value3 => 1, value4 => 12, v +alue5=>978); my (@keys,$key); @keys = sort { $hash{$a} <=> $hash{$b} } keys %hash; foreach $key (@keys) { print "$key: $hash{$key}\n"; }
In reply to hash sort by the values and get the keys by vinoth.ree
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |