in reply to Re^2: hash sorting/alphabetization issue : country postal codes
in thread hash sorting/alphabetization issue : country postal codes
I see that I needed to sort previous to the foreach loop rather than in it.
No, that's not the problem you were having. And there's no problem with putting the sort inside the foreach statement.
my @codes = map { substr($_, 0, rindex($_, '.')) } @intl_files; foreach my $code ( sort { $country_names{$a} cmp $country_names{$b} } ) { print "<option value=\"$code\">$country_names{$code}</option>\n"; }
|
|---|