for my $key (sort {$hash{$a} cmp $hash{$b}} (keys %hash)) { print "Key = $key, Value = $hash{$key}\n"; }