my %hash = ( 'A' => 5, 'B' => 4, 'C' => 3, 'D' => 2, 'E' => 1 ); for my $key (sort { $hash{$b} <=> $hash{a} } keys %hash) { #... }