Text/Line Sorter

Line Sorter

Sort, reverse, dedupe and shuffle lines

Lines — input0 lines
Result — output

Sorting and deduplicating lines is the kind of task that is trivial in a shell and awkward everywhere else. Keeping an import list, a set of allowed values or a translation file in sorted order pays off immediately in code review, because a sorted list produces a one-line diff when something is added instead of a reshuffled block.

The one thing worth understanding is that "alphabetical" is not a single answer. A plain sort compares code points, which puts every capital letter before every lower-case one and orders accented characters after Z. Numeric sorting is different again: as text, 10 sorts before 9. This tool offers each mode explicitly rather than guessing.

How to use it

  1. Paste your linesOne item per line. Blank lines can be stripped as part of the operation if they are noise rather than structure.
  2. Choose the operationSort ascending or descending, reverse the current order, remove duplicates, or shuffle. Operations can be combined — deduplicate and then sort is the common pairing.
  3. Pick the comparisonCase-sensitive sorting is predictable but puts capitals first. Case-insensitive matches what people expect from an alphabetical list. Numeric sorting compares values rather than characters.

Frequently asked questions

Why do capital letters sort before lower-case ones?

Because a default sort compares character codes, and in ASCII every capital letter has a lower value than every lower-case one. So Zebra sorts before apple. That is correct code-point ordering and almost never what a human means by alphabetical — use the case-insensitive mode for a human-facing list.

How do I sort numbers correctly?

Use numeric sorting. Compared as text, 10 comes before 9 because the character 1 precedes 9, so a version list or a set of IDs ends up in the wrong order. Numeric mode parses each line as a value first. Mixed content — text with numbers embedded — needs natural sorting, which segments digits from letters.

Does removing duplicates preserve order?

Here it keeps the first occurrence of each line and drops later ones, so the original order survives if you deduplicate without sorting. That matters when the order carries meaning, such as a precedence list.

Are lines differing only in whitespace treated as duplicates?

No — a trailing space makes a line distinct, and that catches people out constantly when deduplicating a pasted list. Trim first if the whitespace is not meaningful, then deduplicate.

How are accented and non-Latin characters ordered?

A code-point sort places them after the entire ASCII range, so é lands after z rather than beside e. Proper alphabetical ordering for a given language requires locale-aware collation, and the correct answer differs by language — Swedish and German disagree about where ä belongs.

Related tools

Nothing left this tab. No request was made, no history was written. Text · Line Sorter