How to use Sort Lines
- Paste your list into the Lines to sort field, one item per line.
- Choose alphabetical, natural, numeric or line-length order.
- Set letter case, blank-line placement and direction. Add a language tag when you need a particular locale.
- Review the sorted list, then copy it.
Example: Sort Lines
Sort three short lines as numbers.
Options
- Sort by
- Alphabetical compares line text. Natural compares digit runs inside text, so item2 comes before item10. Numeric compares leading numbers, so 10 follows 2. Line length puts the shortest lines first and breaks ties alphabetically.
- Sorting language
- Optional. A tag such as en, de or pt-BR changes how accents and case are ordered. Empty uses the browser's locale.
- Letter case, Blank lines and Lines without a number
- Case can be ignored or kept separate. Blank lines can stay, move to either end or be removed. A line with no leading number goes first or last by your choice.
Supported inputs and limits
- Up to 2,000,000 characters and 200,000 lines.
- Numbers with more than 15 significant digits are compared as text, because a JavaScript number would no longer hold the digits you typed.
- In numeric mode, a line that does not start with a digit, a sign or a decimal point counts as text.
- With no language tag set, letter order follows the browser's locale, so the same list can sort differently on two machines.
- Text containing an incomplete character is refused instead of sorted unpredictably.
More details
Natural order places item2 before item10 without treating the whole line as a number.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
Text order and number order answer different questions
Alphabetical sorting compares line text, so 2, 10, 1 becomes 1, 10, 2. Numeric sorting reads numbers first, so the same input becomes 1, 2, 10. Use numeric order for quantities; use natural order for labels such as item2 and item10. Keep identifiers as text when their spelling, including leading zeros, matters.
Locale affects accents and case
A language tag selects the browser's collation rules for that locale. Different languages can place the same accented letter differently, so there is no single alphabetic order that suits every list. An empty tag follows the browser's locale. Set the intended language and check important edge cases; browsers can still carry different versions of locale data.
Questions about Sort Lines
Why did 10 come before 2?
Alphabetical order compares text, and the digit 1 sorts before 2. Switch Sort by to numeric order and the list becomes 1, 2, 10.
Why did one of my numbers end up in the wrong place?
A line that does not start with a number counts as text, and a number longer than 15 significant digits is compared as text.
Do repeated lines stay in their original order?
Yes. Lines that compare the same keep their original order, so an already sorted list is not shuffled.
Why does the same list sort differently on another computer?
With the language tag empty, the order follows each browser's locale. Setting a tag such as en or pt-BR makes the chosen language explicit and the result more consistent, though locale data can still differ.