Sort keys in a hash : sort « Hash « Perl
- Perl
- Hash
- sort
Sort keys in a hash
$hash{fruit} = apple;
$hash{sandwich} = hamburger;
$hash{drink} = bubbly;
foreach $key (sort keys %hash) {
print "$key => $hash{$key}\n";
}
Related examples in the same category