Thread
:
how to (really) sort a hash by key in Perl
View Single Post
03-10-2005, 12:01 PM
Big E
Registered User
Industry Role:
Join Date: Mar 2002
Location: San Diego, CA
Posts: 935
Quote:
Originally Posted by
teksonline
foreach $code (sort { $countries{$a} cmp $countries{$b} } keys %countries) { do this...
FYI - That sorts by VALUE, not KEY.
foreach $Key ( sort %hash ) {
print "$Key => " . $hash{$Key} . "\n";
}
Big E
View Public Profile
Visit Big E's homepage!
Find More Posts by Big E