in reply to Best 20 after sort

You can use Sort::Key::Top, in particular if you want to extract the top 20 for a large array:
use Sort::Key::Top qw(nkeytopsort); my @top20 = nkeytopsort { $Averages{$_} } 20 => keys %Averages;