I have file containing information about different locations. The location names are the unique values. Some cities will have more than one location.
How do I sort the data by city and then by name and still return all the names?
Right now I have the following code:
while($line = <DATA>){ chomp $line; ($junk,$o_country,$o_province,$o_tcenter,$o_addr +ess,$o_city,$o_stprov,$o_mailcountry,$o_postalcode,$o_firstname,$o_la +stname,$o_title,$o_phone,$o_fax,$o_date) = split(/\|/,$line); #the hashes are filled using the test center as the key $testcenters{$o_city} = $o_tcenter; $centercity{$o_tcenter} = $o_city; ... (more values stored) @mycenters = sort byString keys %testcenters; #returns list of centerc +ity in alpha order foreach $city(@mycenters){ foreach $center($testcenters{$city}){ print "$testcenters{$city}<BR>"; #print testcenter name ... (print more stuff here) } }
I know that is wrong because if there are duplicate cities, then only one location name is returned and the other is skipped.
I've stared at this off and on for, honestly several years, and I the issue came up again today and I realized it was time to ask and hope it was some just obvious solution.
Original node content and title restored by GrandFather
In reply to How to sort a non-unique value within unique values by hmbscully
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |