Sorting text files or other data, for example with the sort utility.

The main purpose of Sort is to sort files and data streams. The sorted result can be written to the standard output or to a specified output file.

Additionally Sort is capable of checking if a file is already sorted and it can merge two already sorted inputs into one output.

To perform the sorting, checking and merging Sort reads in entire lines and for each line it extracts one or multiple sort keys. It then sorts all lines by comparing the extracted sort keys.

How the sort keys are extracted from a line can be specified also how the sort keys are compared can be specified via command line flags.

Sort first appeared in Version 3 of the AT&T Unix and since then it has found its way into all Unix like Operating Systems, the POSIX standard, and the Single UNIX Specification.

Further reading