So the essence of your problem is how to sort these funky codes. Well, it would help if you could give a precise definition of their format, rather than making us guess. I'm guessing that the first number (the 5 and 6 in your examples) could be more than one digit wide, and that there are always exactly two capital letters in the third part.
sub codes_sorted
{
# do the GRT dance
map { substr $_, 10 }
sort
map { /-(\d+)-([A-Z]{2})(\d+)/; pack('N',$1).$2.pack('N',$3).$_ }
}
Then you can do
print OUT join ', ', codes_sorted( keys %{$data{$name}} );