๐Ÿ“š General & Other

Stable Sorts, Locale, and Sorting Larger Than Memory

handles ascending order. Three properties are worth knowing before relying on it in a pipeline.

sort handles ascending order. Three properties are worth knowing before relying on it in a pipeline.

Stability is not the default

A stable sort preserves the relative order of equal keys. GNU sort is not stable unless given -s. When sorting by a secondary field, instability silently reshuffles rows that tie โ€” which matters whenever the existing order carried information.

Locale decides the comparison

LCALL=C gives byte order: deterministic, fast, and it places all uppercase before all lowercase. A language locale gives case-insensitive, accent-aware ordering that varies between systems. For anything feeding comm or join, force LCALL=C on every step so the orderings agree.

It already handles huge files

sort performs an external merge sort, spilling to temporary files when input exceeds memory. It will sort a file far larger than available RAM without complaint โ€” -S tunes the buffer and -T chooses the spill directory, which matters when /tmp is small.

Try it: Sort A to Z on SeoWolf's Notepad.