in reply to difficulty in multi sorting

you probably want to get the data into some structure before processing it. So why don't you read through your file and 'feed' a Hash of Array in a way like:
... my %hash; while (<IN>) { my $name = ... my $code = ... push @{ $hash{$name} }, $code; }
Then you can loop through the sorted hash keys and print the name together with all it's (sorted) codes.
foreach my $name (sort keys %hash) { print join (', ', $name, sort @{ $hash{$name} }), "\n"; }
That's some sort of pseudo code, so it will not work as is. .. ;)