🔤 Text Sorter

Sort text lines alphabetically, numerically, or by length. Ascending or descending — instant, in-browser, no upload.

About the Text Sorter

The text sorter arranges the lines of your input using one of three strategies: alphabetical (lexicographic), numeric (treating the leading number on each line as the sort key), or by line length. Choose ascending or descending order, and toggle case-insensitive matching for alphabetical sorts. Everything runs locally in your browser.

Use it to tidy lists, rank items by length, or order mixed text/number lines consistently. Lines without a numeric prefix are placed together when sorting numerically, and empty lines are preserved as part of the input rather than discarded.

How it works

  • Alphabetical — Uses locale-aware string comparison. With case-insensitive on, comparisons use a casefold; otherwise they fall back to the default code-point order.
  • Numeric — Extracts the leading number (integer or decimal) on each line and sorts by that value. Lines without a leading number are kept at the end in original order.
  • Length — Sorts by character count of each line, shortest to longest (ascending) or longest to shortest (descending).

How to use the sorter

  1. Paste your text (one item per line) in the input box.
  2. Pick a Sort by mode and an Order.
  3. Optionally toggle Case-insensitive for alphabetical sorts.
  4. Click Sort, then Copy the result or Clear to start over.

Frequently asked questions

How are empty lines handled? Empty lines are kept in the input. In length sort they sort first (ascending) or last (descending); in other modes they sort as the empty string.

What counts as a number for numeric sort? A leading integer or decimal (optionally signed) at the start of the line. Lines without one are grouped at the end.

Does it upload my text? No. All sorting happens locally in your browser. Your text never leaves your device.

Is sorting stable? JavaScript's Array.prototype.sort is stable in modern browsers, so equal-key lines keep their original relative order.