in reply to Sorting Hash By Large Number Values

The 'fixed' OP will nevertherless continue running through items 11 thru millions and test against $c for all those iterations. How about using 'last' to get out of the loop when the job is done. I also rearranged the condition handling for brevity:
$NumOfPortsToGet = 10; $c = 0; foreach $key (sort {$Stats{$a} <=> $Stats{$b}} keys %Stats) { ( $c < $NumOfPortsToGet ) or last; ($key eq "UnauthOrigin") or $Ports[$c++] = $key; }

One world, one people