There is an all-purpose sorting utility on UNIX called sort. It has quite a few options, one of which is the ``-u'' (unique) which removes the need to pipe the output of sort into the uniq program.
You can sort files in alphabetical, numerical or phone directory orders, you can reverse the sense of the sort, you can sort on one (or more) fields, with the field definition left to the user, ignore case, etcetera.
For example, you might want to sort the password file (/etc/passwd) based on what login shell each user had. We will note that the fields in this file are separated by colons.
sort -t: +6 /etc/passwd