Are you sure? On my box this is the same...
#!/usr/local/bin/perl
$num=5;
my %hash = ('1' => 12, '2' => 34, '3' => 56, '4' => 2);
@values = reverse ((sort {$a <=> $b} values %hash)[0..--$num]);
print @values, "\n";
$num=5;
@values = (sort {$b <=> $a} values %hash)[0..--$num];
print @values, "\n";
----->
/home/jonathan> z
5634122
5634122
"We are all prompted by the same motives, all deceived by the same fallacies, all animated by hope, obstructed by danger, entangled by desire, and seduced by pleasure."
- Samuel Johnson | [reply] [d/l] |
:-), if num is 5 and theres only 4 in the hash it should be.
try dropping num to a number lower than the number of keys so you get a subset.
| [reply] |