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
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)
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.
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.
Try it nowβ
The full text-sorter runs in your browser at https://ztools.zaions.com/text-sorter β no signup, no upload, no data leaves your device.
Last updated: 2026-05-05 Β· Author: Ahsan Mahmood Β· Edit this page on GitHub