Text Sorter

Sort lines by text, natural digit runs or exact decimal value. Choose a simple delimited field, preserve stable ties, and review optional blank or duplicate removal.

Stable line sorting

Runs in your browser

Equal sort values keep source order, even descending. Original lines are not rewritten. Natural mode treats digit runs as unsigned integers, not signed decimals or software versions. Numeric mode rejects grouping, exponents and empty keys. Field selection is literal splitting, not quoted CSV parsing.

Enter your own values to calculate.

Your result appears here

Enter values and calculate. Changing an input clears the previous result.

Inputs stay in this page. Normal assets and visit-statistics requests still occur. Downloads contain the values you entered.

How this calculator works

Sort by an explicit key while keeping each original line

Text mode compares Unicode code units, not dictionary order. Natural mode treats each run of digits as an unsigned integer: file2 sorts before file10. Leading-zero variants such as file2 and file02 compare equal and keep their original order. Numeric mode compares signed decimal values exactly, including long integers and small fractions; it does not convert them to floating-point numbers.

The editable example file10, file2, file02, file1 becomes file1, file2, file02, file10. Descending order becomes file10, file2, file02, file1: equal-value ties are not reversed. Natural mode is not signed-decimal, date or software-version sorting. Use Numeric for ordinary signed decimal values, such as -2.5 and 0.003. Grouped values, exponent notation, NaN, Infinity and empty numeric keys are rejected.

A key can be the whole line or a numbered field separated by a tab, comma, pipe or custom literal string. This is not quoted CSV parsing. For example, sorting name|12 and other|3 numerically by field two retains the entire original lines while comparing 12 and 3. Missing fields either stop with an error or become empty keys; an empty numeric key still fails numeric validation.

Key trimming, Unicode lowercase and NFC normalization do not rewrite output. Duplicate removal is optional: identical original lines or identical key text. It does not treat 1 and 1.0, or file2 and file02, as identical key text merely because their sort values tie. Output retains stable source order within ties. A final newline terminates a line rather than adding a phantom line; genuine blanks can be retained or dropped.

Text sorting FAQ

Is Text mode alphabetical in my language?

No. It uses deterministic JavaScript Unicode code-unit comparisons, not locale-aware collation, accent folding or natural-language dictionary rules. Ignore case uses Unicode lowercase, not a locale-specific identity rule. NFC combines canonically equivalent text for comparison only.

Why do equal values keep their order when descending?

The sort direction changes comparisons of unequal values only. Equal values always use their original source-line order. That includes numeric 1 and 1.0, or natural file2 and file02. This avoids reversing records that have equal keys.

Can I sort CSV or version numbers?

Field selection is literal splitting, without quotes or embedded-record parsing. Do not use it as a CSV parser when delimiters or newlines occur inside quoted cells. Natural sorting handles unsigned digit runs, not semantic versions, signed decimals, dates or scientific notation.

What does duplicate removal keep?

It keeps the first original line for each identical original text or identical comparison-key text, according to the selected rule. Key options can intentionally merge case or whitespace differences. Numeric equivalence alone does not remove 1.0 when the key text is 1. Original line content is not trimmed or reformatted.

What limits, exports and privacy apply?

Use at most 1,000,000 UTF-16 code units and 10,000 lines, without null characters. Numeric keys allow up to 1,000 characters; field numbers are 1–100, custom separators 1–10 characters without newlines. The table previews 200 rows; TXT, CSV and JSON are complete. CSV includes removed rows and source positions, with formula-like cells protected. Nonempty output has a final LF. Inputs are not uploaded or saved; normal assets and visit statistics still occur.