OmniTools
textDifficulty: 2/5

Sort Lines

Sort lines alphabetically, numerically, by length or in natural order, ascending or descending, with deterministic and reproducible results.

Sort mode

A to Z by character order

By the leading number on each line

Shortest line first

file2 before file10

Reverse the input order without sorting

Sort from the end to the beginning (Z to A, longest first).

Treat "A" and "a" as different characters instead of folding case before comparing.

Compare each line without its leading and trailing spaces or tabs.

Drop blank lines before sorting; they do not appear in the output.

Deterministic ordering: Comparisons use code-unit order rather than localeCompare, because locale collation depends on the browser’s Unicode data and the reader’s language settings — so the same input would otherwise sort differently on two machines. The sort is stable: lines whose keys compare equal keep their original input order.

How it works

  1. Type or paste the lines you want sorted.
  2. Pick a sort mode and any options; the result updates as you type, in your browser.
  3. Copy the sorted lines or download them as a .txt file.
Privacy & Processing: Everything runs in your browser. Nothing you enter is uploaded, stored, or sent to analytics.

Frequently Asked Questions

Why is the ordering deterministic rather than locale-aware?

Comparison uses code-unit order, not localeCompare. Locale collation depends on the browser’s Unicode data and the reader’s language settings, so the same input can sort differently on two machines. A utility whose output is not reproducible is not much of a utility.

What does numeric sort do with lines that are not numbers?

It sorts by the leading number on each line, and lines with no number sort AFTER all the numbers, keeping their original relative order. The count of non-numeric lines is reported. Dropping them, or treating them as zero, would silently lose or reorder your data.

What is natural sort?

It compares digit runs as numbers rather than text, so file2 comes before file10 instead of after it. Ordinary alphabetical sort gives file1, file10, file2, which is almost never what you want for numbered items.

Is the sort stable?

Yes. Lines that compare equal keep the order they had in the input, which matters for length and numeric sorts where many lines share a key.

Related Tools