Sort Lines

Sort lines by alphabetical, numeric or length order, with control over case, blanks and direction.

Inputs stay on your device No sign-up Free to use
How this works

The tool runs in this browser. Your file or text is not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.

Privacy details

Sort the lines controls

Showing an example. Edit to see your own.

One item per line. Duplicate lines are kept.

Optional. A language tag such as en, de or pt-BR changes how accents and letters compare. Leave empty for the browser default.

Alphabetical order sorts 2, 10 and 1 as text. Numeric order reads them as numbers: 1, 2, 10.

Reverses the chosen order.

Used by numeric order only.

Processed in your browser. Your inputs stay on this device.

How to use Sort Lines

  1. Paste your list into the Lines to sort field, one item per line.
  2. Choose Sort by: alphabetical order, numeric order or line length.
  3. Set letter case, blank-line placement and direction, and add a language tag to make the language explicit.
  4. The sorted list updates as you change the options. Copy the result.

Example: Sort Lines

Sort three short lines as numbers.

You add
Lines to sort: 2, then 10, then 1. Sort by: Numeric order (1, 2, 10). Letter case: Ignore case. Blank lines: last. Lines without a number: last.
You get
The summary reports Sorted 3 lines in numeric order, ascending, and the output is 1, then 2, then 10. None of the three lines was read as text.

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

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.

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.

Unicode Technical Standard #10, Unicode Collation Algorithm

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.

Project manager: Tony Hines · Content updated 29 September 2026 · Report a problem