foreach $key ( <1e6 sorted items> sort <1e6 unordered items> keys %h) { print "$key: $h{$key}\n"; }