Sort Lines splits the input on newline characters, applies a comparator chosen from the eight sort modes (alphabetical, length, numeric, word-count, natural, random, reverse, column), and joins the result back with newlines. The underlying engine is JavaScript's built-in Array.prototype.sort, which the V8 and SpiderMonkey teams implement as a stable Timsort variant. Since the 2019 ECMAScript spec, sort stability is guaranteed across browsers, so equal keys keep their original relative order.
Alphabetical mode uses String.prototype.localeCompare, which respects the user's locale collation rules: in English the order matches dictionary expectations (a before A in case-sensitive mode, both equivalent in case-insensitive mode), in German the eszett ß sorts near 'ss', and in Swedish ä sorts after z. This is more correct than a naive Unicode code-point comparison, which would put 'Z' (U+005A) before 'a' (U+0061) and break for any non-ASCII text.
Natural sort handles strings that mix letters and digits — 'file2' before 'file10' — by chunking each line into runs of digits and runs of non-digits, then comparing chunk-by-chunk. Numeric chunks are compared as numbers, alphabetic chunks via localeCompare. This matches Windows Explorer's file ordering and is the only correct option for version strings, paginated filenames, and ticket numbers.
Numeric mode extracts the first number it can parse from each line (matching the regex /-?\d+(?:\.\d+)?/) and sorts on that. Lines with no parseable number sort as zero and clump together. This is useful for sorting log lines by timestamp prefix or CSV rows by a specific column once you have isolated it. For full numeric precision use the column mode with a delimiter that matches your data.
Column mode splits each line on a chosen delimiter (tab, comma, pipe, or custom), takes the nth field, and uses that as the sort key. The remaining fields ride along — only the sort key is extracted, not the line contents. This is the right tool for sorting CSV-like text by a non-first column without round-tripping through a spreadsheet.
Random mode uses the Fisher-Yates shuffle backed by Math.random(). For small lists this is fine. If you need cryptographically random shuffling (for raffles or unbiased trial assignment) the underlying Math.random is not suitable — use crypto.getRandomValues in a small script instead. The shuffle is in-place on a copy, so the original input is preserved.
Empty-line handling is independently configurable: keep, remove, push to top, or push to bottom. This matters when sorting blocks of text where blank lines are paragraph separators. The deduplicate option runs after sorting and removes adjacent equal lines, which is a one-line dedupe given the input is already sorted (Set-based dedupe is faster but does not require sorting). Sorting plus dedupe matches the behavior of Unix `sort -u`.