#!/afs/athena/contrib/perl/p

while(<>){
    chop;
    tr/A-Z/a-z/;
    ($name, $port) = split(':', $_);
    @host = split('\.', $name);

    $alpha{$_} = join('.', reverse @host);
#    print("$_ becomes $alpha{$_}\n");
}

@sites = sort bydom keys %alpha;

sub bydom { 
#print("$a vs. $b\n"); 
return 1 if $alpha{$a} gt $alpha{$b};
return 0 if $alpha{$a} eq $alpha{$b};
return -1 if $alpha{$a} lt $alpha{$b}; }

for $s (@sites){
    print("$s\n");
}
