Sort Lines
Put newline-separated items in alphabetical order, reverse the order, or compare embedded numbers naturally. Duplicates remain in the result.
Runs locally in your browser
Discuss a result
Write a short summary and review it before posting. Your tool inputs are never copied automatically.
What is the Sort Lines?
Put newline-separated items in alphabetical order, reverse the order, or compare embedded numbers naturally. Duplicates remain in the result.
How to use it
- 1Paste one item per line.
- 2Choose ascending or descending order and natural number sorting.
- 3Copy the sorted list.
How it works
The browser’s Intl.Collator compares lines. Natural number mode treats the digits in “Item 2” as smaller than the digits in “Item 10.”
Natural order
Item 10, Item 2, Item 1 sorts to Item 1, Item 2, Item 10 when natural number order is enabled.
Limitations & notes
- Sorting rules can differ slightly across browser locales.
- Blank lines are retained and sorted with the other lines.
Frequently asked questions
Why does Item 10 come before Item 2 in some sorts?
Plain alphabetical sorting compares text character by character, and the character 1 sorts before 2, so Item 10 lands ahead of Item 2. Natural number order reads each run of digits as a whole number instead, giving Item 1, Item 2, Item 10. This tool has natural order switched on by default; untick it if you need strict character order, for example to match how a program or database without natural collation would sort.
Are uppercase and lowercase sorted separately?
No. The comparison ignores case and accents, so apple, Apple and Äpple are treated as equal and grouped together instead of all capitals appearing first as in a raw ASCII sort. Lines that compare equal keep their original relative order in ascending mode. Descending mode simply reverses the finished list, so those tied lines appear in reverse input order.
How do I sort version numbers like 1.5 and 1.10?
With natural order on, each group of digits is compared as an integer, so v1.10 sorts after v1.5 because 10 is greater than 5. That matches how software versions work. It does not match decimal numbers: as decimals, 1.10 is smaller than 1.5. For a list of prices or measurements with differing decimal places, pad them to the same number of decimals first, such as 1.10 and 1.50, so both readings agree.
Why did a line jump to the top of the sorted list?
Most often it starts with a space, tab or punctuation mark, which sorts before letters and digits. In the tool, a line written as " Zeta" with a leading space ends up above apple. Remove leading whitespace with a text cleanup tool, or fix those lines by hand, and sort again. Empty lines are kept and also gather at the top in ascending order or at the bottom in descending order.
Can I sort and remove duplicates at the same time?
This tool only reorders lines; every duplicate stays in the result, which can be useful for spotting repeats because identical entries end up next to each other. To get a sorted list of unique values, run the list through the Duplicate Line Remover first and then sort the output here. The order of the two steps does not change which values remain.
No directly related discussion yet.
Start a focused thread and share the question this tool helped you explore.
Ask the community about Sort Lines