Format

Sort any list of lines into alphabetical or numerical order

Sort any block of text lines alphabetically, reverse alphabetically, or numerically.

🛡️ Your rows never leave your browser.
Why Onfyt: Numerical sort treats each line as a number rather than a string — so '10' sorts after '9', not between '1' and '2'.

Interactive Sample Data

idline
1Mombasa
2Nairobi
3Eldoret

How this tool works

Sorted lists are easier to scan, deduplicate by eye, and merge with other sorted datasets. A list of country names, product codes, error messages, or domain names becomes immediately useful once sorted. The engine splits the input on newline characters, applies the chosen sort key, and reassembles the lines in the new order. Blank lines can be moved to the top, bottom, or removed entirely. Sort modes available through your instruction: - **A–Z** (default): standard lexicographic ascending order. - **Z–A**: reverse lexicographic descending order. - **Case-insensitive**: 'banana' and 'Banana' are sorted as equivalent. - **Numerical**: lines are parsed as numbers first; non-numeric lines fall to the end. - **By length**: shorter lines first (or 'longest first' to reverse). - **Remove blank lines before sorting**: empty lines are discarded before the sort. All sorting runs inside your browser tab — no data upload.

Things that usually go wrong

  • Standard (string) sort puts '10' before '2' because '1' < '2' in ASCII — use 'sort numerically' to fix this.
  • Mixed-script lines (some Latin, some Arabic) sort by Unicode code point, which may not match user expectations — sort Latin lines separately.
  • Lines ending with Windows CRLF (\r\n) may sort after equivalent Unix LF (\n) lines — the tool normalises line endings before sorting.

Edge cases we tested

🧪 Numerical sort on mixed list ('10', '9', '100', '2')

Sorted 2, 9, 10, 100 — numeric value used, not string comparison.

🧪 Lines with leading spaces (' apple' before 'banana')

Leading spaces are significant in default sort; space sorts before letters in ASCII.

🧪 Case-insensitive sort with duplicate casing ('Apple', 'apple')

Both lines kept; their relative order matches the original input (stable sort).

🧪 Blank lines in the input

Blank lines sort to the top in ASCII order by default; use 'remove blank lines' to eliminate them first.

🧪 Single-line input

Returned unchanged — sorting one line produces one line.

Frequently Asked Questions

Does sorting remove duplicate lines?

No — it only reorders them. Use 'Remove Duplicate Lines' before or after sorting to collapse duplicates.

Can I sort in reverse alphabetical order?

Yes — add 'Z to A' or 'reverse' to your instruction.

Is the sort stable?

Yes. Lines that compare as equal preserve their original relative order.

Can I sort by the second word on each line?

Add 'by the second word' to your instruction — the engine uses the second space-delimited token as the sort key.

Related tools

Clean

Remove Duplicate Lines

Remove repeated lines from any text block, with options for case sensitivity and whitespace handling.

Open Tool →
Clean

Remove Empty Lines

Remove all blank and whitespace-only lines from any block of text.

Open Tool →
Clean

Remove Extra Spaces

Collapse multiple consecutive spaces into one and strip leading/trailing spaces from any text.

Open Tool →
Format

Sort CSV by Column

Sort tabular CSV records ascending or descending by any column value.

Open Tool →