Sort Lines
Sort lines of text online alphabetically, naturally (item 2 before item 10), by number or by length, in ascending or descending order. Runs in your browser.
Runs in your browser · Nothing uploadedFree · No sign-up
Something not working, or missing a feature? Send feedback
About the Sort Lines
The Sort Lines tool sorts a list alphabetically, naturally (so item 2 comes before item 10), by a leading number or by length, ascending or descending. It can also reverse the current order, drop empty lines and remove duplicates in the same step.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the Sort Lines
- Paste your text, one item per line.
- Pick the sort order and the direction, and choose whether upper and lower case are sorted separately.
- Optionally remove duplicates and empty lines, then copy or download the sorted list.
Examples
Input
file10.txt file2.txt File1.txt file20.txt file3.txt
Result
File1.txt file2.txt file3.txt file10.txt file20.txt
Numbers are compared by value, and upper and lower case are sorted together.
Input
file10.txt file2.txt File1.txt file20.txt file3.txt
Result
File1.txt file10.txt file2.txt file20.txt file3.txt
Character-by-character comparison puts file10.txt before file2.txt. This is why natural sort is the default.
Input
42 Oslo 7 Paris -3 Reykjavik 100 Lima Tokyo
Result
100 Lima 42 Oslo 7 Paris -3 Reykjavik Tokyo
Lines are ordered by their leading number. Tokyo has no number, so it goes last in either direction.
Common mistakes
- Alphabetical sort for numbered items. Alphabetical order puts 10 before 2. Use natural or numeric sort for anything with numbers in it.
- Sorting lines that belong together. Sorting works line by line, so multi-line records (such as addresses) get split apart. Put each record on one line first, for example as CSV.
Works well with the Sort Lines
- Remove Duplicate Lines: remove duplicates without changing the order.
- Case Converter: normalise the case of every line first.
- Text & Code Diff: compare two sorted lists.
Frequently asked questions
What is natural sort?
Natural sort compares numbers inside text by value, so file2.txt comes before file10.txt. A plain alphabetical sort compares character by character and puts file10.txt first, because "1" sorts before "2".
How does numeric sort work?
Lines are ordered by the number they start with, including negative and decimal numbers. Lines that do not start with a number go to the end.
Is sorting the same in every language?
This tool uses English collation rules for consistent results. Accented letters sort next to their base letter, for example é next to e.
Related tools
Word & Character Counter
Count words, characters, sentences and paragraphs online with reading and speaking time, keyword density, SMS parts and limits for X, Instagram and meta tags.
Runs in your browserCharacter Counter
Count characters online with and without spaces, plus letters, digits and emoji. Check X, Instagram bio and meta limits, trim to fit, see character frequency.
Runs in your browserCase Converter
Convert text between camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case and more online. Rename variables and keys in one paste.
Runs in your browserRemove Duplicate Lines
Remove duplicate lines from text online, keeping the first occurrence and the original order. Optionally ignore case, extra spaces and empty lines.
Runs in your browserRemove Line Breaks
Remove line breaks from text online: join broken lines from a PDF or email into one paragraph, or into a comma-separated list. Optionally keep paragraph breaks.
Runs in your browserRemove Extra Spaces
Remove extra spaces from text online: collapse repeated spaces and tabs, trim every line and squeeze blank lines. Clean pasted text in one click.
Runs in your browser