Sort lines
Sort a list alphabetically or in natural number order, ascending or descending, while preserving duplicates.
How it works & useful details
How to use this tool
Paste one item per line and choose the sorting method and direction. Natural number order puts item2 before item10. Duplicates stay in the result.
How the result is calculated
Sorting uses your browser’s English Intl.Collator. By default, case and accents compare equally; enable the distinction when needed. Ties keep their original order in both directions. Leading/trailing spaces are retained and participate in sorting. This is not a decimal, signed-number, or version-number parser.
Line tools normalize CRLF and CR to LF. A final newline represents an empty final line; empty input has zero lines.
Up to 500,000 UTF-16 code units per input. Text stays on your device.
About this tool
Sort lines orders a list alphabetically or in natural number order, ascending or descending, and keeps duplicates intact. Natural order sorts item2 before item10, which plain text sorting gets wrong.
Sorting is stable and local, and the cleaned result can be copied or downloaded. No data is sent anywhere.
How to use it
- Paste the list, one item per line.
- Choose alphabetical or natural ordering.
- Select ascending or descending direction.
- Review the sorted list and copy or download it.
Worked example
Sorting item10, Item2, item1, Éclair, apple, banana:
Alphabetic: apple, banana, Éclair, item1, item10, Item2
Natural numbers: apple, banana, Éclair, item1, Item2, item10Alphabetic order compares character by character, so "item10" comes before "Item2" because 1 sorts before 2. Natural order reads digit runs as numbers, which is what people expect for file names, versions of chapters, and numbered items. Accented letters are sorted with their base letter (É with E), not after Z as in a plain character-code sort.
Sorting details
By default, case and accents do not affect the order, so "apple" and "Apple" sort together. Enable "distinguish case and accents" for stricter ordering. Lines that compare as equal keep their original relative order, which is called a stable sort. Duplicates are kept. Remove them before or after sorting with remove duplicate lines.
Leading spaces count, so an indented line sorts before unindented ones. Trim whitespace first if that is not intended. Natural order does not understand negative numbers, decimals, or dates. Sort ISO dates (2026-09-24) alphabetically, since that format already sorts correctly as text.
Frequently asked questions
What is natural sort order?
Numbers inside text are compared by value, so "item2" comes before "item10" instead of after it in dictionary order.
Are blank lines sorted with the rest?
Blank lines participate in the ordering; remove them first if they should not appear at the top of the result.
What is the limit?
Up to 500,000 characters of text.
Can I sort by a column in CSV data?
Use CSV sort for that. It understands quoted fields and lets you choose the column and a numeric or text comparison.
