in reply to How to sort a non-unique value within unique values

Use a hash of arrays. When populating them:

push @{$testcenters{$o_city}, $o_tcenter;
Then to sort them:
for my $city (sort keys %testcenters) { for my $center (sort @{$testcenters{$city}}) { print "$city: $testcenters<br>"; } }
(I could make lots of comments about your variable names, using strict.pm, the way you've embedded HTML in your code, etc, etc, etc. But I'd wind up writing a book, so I'll just suggest reading Perl Best Practices and Code Complete instead.)