and/or using something like the *nix 'sort' command
For you Windows users, there's a pipeable sort.exe that comes with windows. Put your text in a file, say text1.txt from notepad or anything, then in a command window type --- sort < text1.txt > text2.txt ---
No, those angle brackets aren't tags, they are redirects :) . It'll create a new text file text2.txt that'll be sorted line-by-line alphanumerically.
Since sort is pipeable, the system() command should be able to deal with it just fine in PHP on Windows. But I've never actually done that.
--NDB