my @ranks = sort { $b <=> $a } keys %rank; for my $r (@ranks) { print "$r $rank{$r}\n"; }