Sort Lines of Text — Alphabetical, Numeric, Length, Reverse (Free)
Sort any list of lines alphabetically, numerically, by length, or reverse. Case options, natural sort for filenames. Free, instant.
About Text Sorter
A text sorter rearranges lines of input into a defined order — alphabetical, reverse alphabetical, numeric, length, or natural — supporting case-sensitive options and stable sort behavior so equal-key lines preserve their relative order. The ZTools Text Sorter handles lists of any size, offers natural-sort mode (so "file2" sorts before "file10" instead of after), supports numeric sort for lists of numbers, length-based sort for finding the longest or shortest entries, and shuffle/randomize as a complementary mode for randomized ordering.
Use cases
- Alphabetizing a name or contact list. A pasted list of attendees, products, or files. One click sorts A→Z. Name-tag printing, alphabetical directories, and filing all benefit.
- Sorting filenames naturally. "file1, file2, file10, file20" sorts naturally (1, 2, 10, 20) rather than lexicographically (1, 10, 2, 20). Critical when filenames contain numbers.
- Finding the longest or shortest entry. Sort by length descending — the first line is the longest. Useful for finding the longest URL, the shortest title, or the wordiest sentence.
- Preparing data for CSV imports. Many database imports require pre-sorted data for indexing efficiency. Sort the column, paste into the spreadsheet, and import.
How it works
- Paste lines into the input. One item per line. Empty lines and whitespace are preserved or trimmed per your option.
- Pick a sort method. Alphabetical (A→Z), reverse (Z→A), numeric (treats lines as numbers), length (shortest or longest first), natural (handles embedded numbers correctly), shuffle (random order).
- Configure options. Case-sensitive: "Apple" and "apple" sort separately. Locale: en-US, de-DE, fr-FR, etc. — affects accented character ordering.
- Read and copy the result. Sorted output appears immediately. One-click copy or download. Original input is preserved if you want to re-sort with different options.
Examples
Input: banana
apple
cherry
Output: apple
banana
cherry
Alphabetical A→Z.
Input: file10
file2
file1
Output: file1
file10
file2 (lex sort) — but with natural sort: file1
file2
file10
Input: 100
20
3
Output: 100
20
3 (lex) | 3
20
100 (numeric ascending)
Numbers as text vs numbers as numbers behave very differently.
Frequently asked questions
What's the difference between alphabetical and natural sort?
Alphabetical sorts character by character — "file10" comes before "file2" because "1" < "2" in character order. Natural sort recognizes embedded numbers — "file2" comes before "file10" because 2 < 10. For filenames and version strings, natural is almost always what you want.
How do uppercase and lowercase affect sorting?
In default ASCII order, uppercase letters (A-Z = 65-90) come before lowercase (a-z = 97-122), so "Zebra" sorts before "apple". Toggle case-insensitive to sort them together.
Why does my numeric list sort weirdly?
Default sort treats each line as text, so "100" comes before "20" because "1" < "2" character-by-character. Switch to numeric mode for lines that are pure numbers.
Does sorting preserve original line content?
Yes — the tool only reorders lines; it doesn't modify them. With case-insensitive sort, "Apple" stays "Apple" — only the comparison ignores case.
Can it handle non-English text?
Yes — pick the appropriate locale to handle accented characters and non-Latin scripts correctly. German uses umlaut equivalencies, French handles accents, etc.
Pro tips
- For mixed lists with numbers and text, natural sort almost always gives the most intuitive result.
- When sorting CSV columns, sort by the column you care about most — numerical IDs, alphabetical names, or chronological dates.
- Stable sort means equal-key lines keep their original relative order; useful when sorting by multiple criteria sequentially.
- For very long lists, consider sorting in chunks if your browser slows down — though the tool handles 1M+ lines natively.
Reviewed by Ahsan Mahmood · Last updated 2026-05-05 · Part of ZTools.
For the full,
formatted version of this page, please enable JavaScript and reload
https://ztools.zaions.com/text-sorter.