in reply to Best 20 after sort

In the spirit of TIMTOWTDI, a different approach using sort, grep and map in a do block.

use strict; use warnings; my %Ave = map { $_ => rand } q{a} .. q{z}; print do { my $count = 0; map { qq{$_\t$Ave{ $_ }\n} } grep { $count ++ < 20 } sort { $Ave{ $a } <=> $Ave{ $b } } keys %Ave; };

I hope this is of interest.

Cheers,

JohnGG