Sort lines

Client-side only. Sort runs in this tab. Nothing is uploaded.

Mode
0Original lines
0Output lines
0Empties skipped

By Cobra · Last updated

How to sort lines

  1. Paste your list, one item per line.
  2. Pick a sort: A to Z, Z to A, natural, or reverse the current order.
  3. Set the options: case sensitive, trim before compare, ignore empty lines, and remove duplicates after sort. Trim only affects how lines are compared. The lines you get back keep their original text.
  4. Read the result and the counts under it: original lines, output lines, and empty lines skipped.
  5. Copy the result or download it.

Worked example: natural sort for numbered files

Five file names, sorted two ways:

A to ZNatural
file1.txtfile1.txt
file10.txtfile2.txt
file2.txtfile3.txt
file20.txtfile10.txt
file3.txtfile20.txt

A to Z compares one character at a time, so "10" comes before "2". Natural sort reads the digits as numbers, which is what people expect for files, versions, and chapter lists.

Worked example: cleaning a keyword list

Seven lines from two spreadsheets: running shoes, Trail Shoes,   running shoes (with leading spaces), an empty line, trail shoes, hiking boots, and Running Shoes (with a trailing space).

Sort A to Z with trim on, empty lines ignored, duplicates removed, and case sensitive off. The result is 3 lines: hiking boots, running shoes, Trail Shoes. The counts read 7 original, 3 output, 1 empty skipped.

Turn case sensitive on and you get 5 lines, because "Running Shoes" and "running shoes" now count as different. For keyword lists, leave it off.

When to use it

Common mistakes

Other list tools

To remove duplicates but keep the original order, use the duplicate line checker. To see what changed between two versions of a list, paste both into text compare. To make case consistent before sorting, run the list through the case converter. For a count of words and lines, the word counter helps.

FAQ

What is the difference between natural and A to Z sort?

A to Z compares text one character at a time, so file10 comes before file2. Natural sort treats runs of digits as numbers, so file2 comes before file10.

How do I remove duplicate lines?

Tick remove duplicates after sort. With trim on and case sensitive off, lines that differ only by spaces or capital letters are treated as the same. The first one found is kept.

What happens to empty lines?

With ignore empty lines on, they are dropped and counted as skipped. Turn it off to keep them in the sorted result.

Is reverse the same as Z to A?

No. Z to A sorts the lines in descending order. Reverse keeps your order and flips it, so the last line becomes the first.

Can it handle a long list?

Yes. Sorting runs in your browser, so lists of many thousands of lines work. Very large pastes depend on your device's memory.