Skip to content
TextBench Lab

Sort Lines

Put any list in order: A to Z, Z to A, natural or numeric order, by length or by a column, or shuffle it. Blank lines and duplicates are handled for you. It runs in your browser, so nothing is uploaded.

Up to 100,000 lines and 1,500,000 characters.

Options

Fields are split at every delimiter; quotes are not read. Equal lines keep their order.

Lines in
0
Lines out
0
Removed
0

How to sort lines

  1. Paste your list

    Put one item on each line, up to 100,000 lines.

  2. Choose the order

    A to Z, natural order for names with numbers, numbers, length, reverse or random.

  3. Adjust the options

    Ignore case, pick a language, sort by a column, and decide what happens to blank lines and duplicates.

  4. Copy the sorted list

    Copy the result, or press Swap to keep working on it.

Features

  • Natural and numeric order

    file2 comes before file10, and 9 comes before 10, as people expect.

  • Language aware

    Accents and letters like ä, ñ or ß are sorted the way your language does it.

  • Sort by a column

    Sort CSV-like rows by their second or third field instead of the whole line.

  • Private

    Everything happens in your browser. Your list is never uploaded or stored.

What this tool does

A list is easier to read, check and compare when it is in order. Paste anything with one item per line, such as names, keywords, file names, prices or rows copied from a spreadsheet, and the sorted version appears right away. You choose the order, how case and accents count, what happens to blank lines and duplicates, and whether to sort by the whole line or by one column. Everything runs in your browser, so the list stays on your device.

The sort orders

  • A to Z and Z to A sort alphabetically. Upper and lower case are treated as the same letter by default, so "apple" and "Apple" sit together instead of all capitals coming first.
  • Natural order reads numbers inside the text as whole numbers. A plain alphabetical sort compares one character at a time, so "file10" lands before "file2", because the character 1 comes before 2. Natural order gives "file1, file2, file10", which is what people expect for file names, chapters, versions and invoice numbers.
  • Numbers sorts by the number at the start of each line: "9 pears" before "10 apples". It understands minus signs, decimals, an exponent such as 1e3 and thousands commas such as 1,234. Lines that do not start with a number go to the end in their original order, whichever direction you choose.
  • Length puts short lines first or long lines first. Length is counted in visible characters, so an emoji or an accented letter counts as one.
  • Reverse current order turns the list upside down without sorting it.
  • Random shuffle mixes the lines. It uses the browser's cryptographic random numbers and the Fisher-Yates method, so every possible order is equally likely. Press Shuffle again for a new one. This is handy for picking a winner, ordering presentations or making quiz questions.

Case, accents and language rules

Computers store letters as numbers, and a sort by those numbers puts every capital letter before every small one and every accented letter after z. That is rarely what you want, so by default the tool sorts with your browser's built-in language rules (Intl.Collator), the same way a dictionary would. "Éclair" then sits next to "eclair", not after "zebra".

Languages disagree about some letters, and the Language rules setting lets you pick one. Swedish puts ä and ö after z, while German sorts ä together with a. Spanish places ñ after n, and Turkish has a dotted and a dotless i that are different letters. If you need a strict, predictable order for code or data, choose Character codes, which compares the raw character numbers with no language rules at all.

Untick Ignore case to keep upper and lower case apart. Ignore spaces at the ends makes " banana" sort as "banana", which helps with lists copied from documents.

Blank lines and duplicates

Blank lines are removed by default, and the count shows how many. You can also move them to the top or the bottom, or keep them in place, so a list split into groups by empty lines keeps its gaps while the items around them are sorted. A line that holds only spaces counts as blank.

Tick Remove duplicate lines to keep only the first copy of each line after sorting. It follows the case and spaces settings, so "Apple" and "apple " count as the same line when both are on. For more control over repeated lines, such as counting or keeping only the repeats, use Remove Duplicate Lines. The guide on how to clean a keyword list shows a full routine.

Sorting by a column

Lines copied from a spreadsheet or a CSV file often look like "Lahore,11126285". Set Sort by to a field number and pick the delimiter (comma, tab, semicolon, pipe or spaces), and the lines are sorted by that column while each line stays whole. Combined with Numbers, largest first, this sorts a list of cities by population in two clicks. The split is simple: every delimiter starts a new field, and quotes are not read, so a quoted value that contains the delimiter is split too.

Equal lines stay in order

When two lines compare as equal, for example "apple" and "Apple" with case ignored, they keep the order they had in your input. This is called a stable sort. It means you can sort by one thing, then by another, and the first order survives inside the groups of the second. Sorting the same list twice always gives the same result.

Line breaks

The tool accepts Windows (CRLF), Mac and Linux (LF) and old Mac (CR) line breaks, even mixed in one text, and uses the most common one for the whole result. A line break at the very end of your list stays at the end.

To see what changed between two lists, sort both and compare them with the text compare tool, as described in how to compare two lists. To make every line the same case first, use the case converter.

Privacy

Your list is not uploaded, saved or tracked, and there is no sign-up. Lists are limited to 100,000 lines and 1,500,000 characters so the page stays fast. Like every page on this site, this one may show ads from third-party vendors once ads are switched on, and those vendors can use cookies. Read the privacy policy for details.

Frequently asked questions

How do I sort lines alphabetically?

Paste your list with one item per line and keep A to Z. Ignore case is on, so Apple and apple sort together. Copy the result when you are done.

Why does file10 come before file2?

A plain alphabetical sort compares character by character, and 1 comes before 2. Choose Natural order to read the numbers inside the text as whole numbers.

How are lines without a number sorted in number mode?

They go to the end of the list in their original order, whichever direction you choose, so they never mix with the numbers.

Is the shuffle really random?

Yes. It uses the browser's cryptographic random numbers and the Fisher-Yates method, so every order is equally likely. Press Shuffle again for a new one.

What happens to lines that are equal?

They keep their original order (a stable sort). Tick Remove duplicate lines to keep only the first one.

Is my list uploaded?

No. Everything happens in your browser and nothing is sent or saved. Lists are limited to 100,000 lines and 1,500,000 characters so the page stays fast.

Topics