How to use Sort Text Lines
Sort lines of text alphabetically, numerically, or in reverse order entirely in your browser — no data leaves your device. Paste any list and choose from multiple sort modes including natural sort (so "item10" correctly follows "item9"), case-insensitive comparison, whitespace trimming, and duplicate removal. Ideal for sorting word lists, log entries, CSV rows, reference lists, or any numbered inventory.
- Paste your list or multi-line text into the input area (one item per line).
- Choose a sort order: A–Z, Z–A, numerical ascending, or numerical descending.
- Toggle "Natural sort" to sort numbered items in human-readable order (item2 before item10).
- Toggle "Case insensitive" to treat uppercase and lowercase letters as equal during comparison.
- Optionally enable "Remove duplicates" and "Trim whitespace" for a cleaner output.
- Click "Sort Lines" — the sorted output appears instantly.
- Copy or download the sorted list.
Your data never leaves your device — 100% private processing.
Lexicographic vs natural sort
Lexicographic (alphabetical) sort compares strings character by character using Unicode code point values. This produces correct results for plain words but counterintuitive results for strings containing numbers: "item10" sorts before "item2" because the character "1" (U+0031) has a lower code point than "2" (U+0032). Natural sort — also called human sort — recognises embedded numeric substrings and compares them as integers rather than character sequences, placing "item2" before "item10". Natural sort is essential for filenames, version numbers (v1.9 before v1.10), and any list where numbers appear within alphabetic strings.
| Input items | Lexicographic | Natural sort |
|---|---|---|
| item1, item10, item2 | item1, item10, item2 | item1, item2, item10 |
| v1.9, v1.10, v1.2 | v1.10, v1.2, v1.9 | v1.2, v1.9, v1.10 |
| file20, file3, file100 | file100, file20, file3 | file3, file20, file100 |
Stable sort and multi-key ordering
A stable sort preserves the original relative order of elements that compare as equal. If two lines — "Apple" and "apple" — are considered equal under case-insensitive comparison, a stable sort keeps them in their original input order, while an unstable sort may swap them arbitrarily. Modern JavaScript's Array.prototype.sort() has been guaranteed stable since ECMAScript 2019, meaning all major browsers now produce consistent results. Stable sorting is important when applying multiple passes — for example, first sorting by category and then by name — because each pass preserves the ordering achieved by the previous one.
Worked examples
Alphabetical A–Z
Inputs: banana / apple / cherry
Result: apple / banana / cherry
Natural sort
Inputs: item10 / item2 / item1
Result: item1 / item2 / item10
Numeric descending
Inputs: 3 / 20 / 100
Result: 100 / 20 / 3
Glossary
- Lexicographic order
- Alphabetical ordering that compares strings character by character using Unicode code point values; the default sort behaviour in most programming languages.
- Natural sort
- A sort algorithm that treats embedded numeric substrings as integers rather than character sequences, producing human-readable ordering for alphanumeric strings.
- Stable sort
- A sorting algorithm that preserves the original relative order of elements that compare as equal, enabling reliable multi-key sorting.
- Collation
- The rules for comparing and ordering strings in a specific language or locale, accounting for accents, case, and locale-specific character ordering.
- ASCII order
- The ordering of characters by their ASCII code point values; digits (48–57) sort before uppercase letters (65–90), which sort before lowercase letters (97–122).
Related reading
Frequently Asked Questions
Why use Sort Text Lines?
- Natural sort mode correctly orders alphanumeric strings so "file10" follows "file9", not "file2"
- Numerical sort interprets each line as a number for correct integer-based ordering of scores or prices
- Stable sort preserves relative order of equal lines, enabling safe sequential multi-key sort passes
- Duplicate removal and whitespace trimming run in the same pass, avoiding extra tool-switching
Common use cases
- Alphabetise a glossary or reference list before pasting it into a documentation wiki page
- Sort a list of version numbers in natural order to identify the latest release in a changelog
- Organise a keyword research list alphabetically before grouping terms into topic clusters
- Arrange a scored task list by numeric priority when the score is embedded at the start of each line
- Sort CSV rows alphabetically by the first column value before importing into a database table
Get weekly tool tips & updates
New tools, power-user tips, and productivity hacks — delivered free every Friday.
No spam, ever. Unsubscribe with one click.
Related Text Tools
Text Diff Checker
Compare two texts line by line and highlight added, removed, and unchanged content instantly for copy review, QA checks, and revision auditing.
Remove Line Breaks
Remove line breaks and paragraph breaks from text online. Replace breaks with spaces, keep paragraphs, and strip extra spaces. Free and private.
Remove Duplicate Lines
Remove duplicate lines from text online. Case-sensitive or insensitive matching. Preserves order or sorts alphabetically. Free online tool.
Reverse Text
Reverse text online by characters, words, or lines. Flip your text backwards instantly. Free, private text reverser that runs in your browser.
Word Counter
Count words, characters, sentences, and paragraphs, and estimate reading time. Free, instant, and private — ideal for essays, articles, and posts.
Case Converter
Convert text to camelCase, PascalCase, snake_case, kebab-case, UPPERCASE, lowercase, Title Case, and Sentence case instantly.
Explore all Text Tools.