How to use Sort Lines
- Paste your list into the Lines to sort field, one item per line.
- Choose Sort by: alphabetical order, numeric order or line length.
- Set letter case, blank-line placement and direction, and add a language tag to make the language explicit.
- The sorted list updates as you change the options. Copy the result.
Example: Sort Lines
Sort three short lines as numbers.
Options
- Sort by
- Alphabetical compares the text of each line. Numeric compares parsed numbers, so 10 follows 2. Line length lists the shortest 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
Where your input is processed
This tool processes your input in this browser. Your text and files are not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.
Text order and number order are different questions
Alphabetical sorting walks the characters of each line, so 2, 10, 1 becomes 1, 10, 2. Numeric sorting parses each line as a number first, so the same input becomes 1, 2, 10. Neither answer is wrong; they answer different questions. Pick numeric order for prices, counts and measurements, and alphabetical order for names, labels and IDs.
Locale decides how accents and case sort
When a language tag is set, the tool compares lines with that locale's collation rules, which puts accented letters where a reader of that language expects them instead of after z. The Unicode collation standard describes those rules in more depth. Leaving the tag empty follows the visitor's own settings.
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.