Joining each element of a list with a newline
@names=('A','C','C','D','E'); @names=join("\n", sort(@names)); print @names,"\n";