my @keys = sort keys %hash; # adapt to your needs here. for (@keys) { print "$_ => $hash{$_}\n"; }