/sɔːrt/

noun … “a Unix command that arranges lines of text in a specified order.”

sort is a command-line utility in Unix-like operating systems used to organize lines of text in files or streams based on lexicographical, numerical, or custom criteria. By default, it arranges lines in ascending lexicographic order, but it supports options for reverse order, numerical sorting, and key-based sorting. This makes sort an essential tool for data organization, preprocessing, and analysis in shell workflows.

The utility works by reading input from files or standard input, comparing lines according to the specified sorting rules, and outputting the ordered result. Flags such as -n perform numerical sorting, -r reverses the sort order, -k specifies sorting by a particular field, and -u eliminates duplicate lines. sort can handle large datasets efficiently and can be combined with other utilities for complex pipelines.

sort integrates seamlessly with other Unix commands. For example, it is often paired with grep for filtered sorting, uniq for removing duplicates, or awk for field-based processing. In shell scripts written in sh, Bash, or ksh, sort enables automated sorting tasks, report generation, and structured data manipulation.

In practice, sort is widely used in system administration, log analysis, text processing, and scripting. It helps organize lists, compare datasets, and prepare data for downstream analysis. Its ability to combine with pipelines and redirection makes it a versatile component in both ad hoc commands and automated workflows.

An example of sort usage:

# Sort a list of numbers in descending order
sort -n -r numbers.txt

The intuition anchor is that sort acts like a “text organizer”: it rearranges data lines into meaningful order, providing clarity, structure, and efficiency for both human inspection and automated processing.