sort command, as the name suggests sorts the lines alphabetically and numerically, automatically. All you got to do is pipe the stdin into sort command.
Important Flags for sort:
|Sorts in reverse order
|This flag is used to check whether the file is already sorted or not(If not, it will list, where the disorder started)
|To sort and removes duplicate lines(does work same as stdin redirected into uniq)
|To save into a output file