foreach my $hash ( sort {$file_hashes{$a} cmp $file_hashes{$b}} keys %file_hashes ) { print "$hash $file_hashes{$hash}\n"; }