Free online tools
English EN, Choose a language

Sort lines

Paste a list and sort the lines A to Z, Z to A, by number or length, or shuffle them fairly at random.

Sort

Sort by a column (optional)

Leave empty to sort by the whole line.

Result

Paste a list, one item per line, then pick how to sort it.

Runs in your browser. Your list is never uploaded or stored.

Related tools

All text tools →

How to sort lines alphabetically

  1. Paste your list, one item per line. Insert example loads a mixed list.
  2. Pick a sort: A to Z, Z to A, by number, by length, reverse the current order, or shuffle.
  3. Tick the options you need: remove duplicates, drop empty lines, ignore capitals. The result updates at once.
  4. Copy it or download a .txt file.

Natural sort: item2 before item10

Plain alphabetical order compares character by character, so item10 lands before item2 (the character 1 comes before 2). Natural order reads the digits as a number. The same list both ways:

item10
item2
Banana
apple
item1
cherry
apple

Apricot
SettingResult (lines joined with ·)
Natural order on (default)apple · apple · Apricot · Banana · cherry · item1 · item2 · item10
Natural order offapple · apple · Apricot · Banana · cherry · item1 · item10 · item2

Natural order is what file managers and spreadsheets show, so it is the default. Sorting uses your browser's language rules, so accented letters sort next to their base letter (é after e) instead of at the end.

Sort numbers, and what happens to lines without one

The number options read the first number in each line, with thousands separators (1,250) and decimals. In this list the amount is the second word, so Sort by column is set to 2:

Rent 1,250
Coffee 4.5
Flight 389
Books 62.99
Notes
Coffee 4.5
Books 62.99
Flight 389
Rent 1,250
Notes

Lines with no number, such as the last one, go to the end and the tool tells you how many there were.

Sort by column or word

Set Word or column number and pick the separator to sort lines by one field while keeping the whole line. Commas make it work for simple CSV lines, tabs for pasted spreadsheet rows. Sorting the people below by the third field (age, low to high):

Smith, Ana, 31
Okafor, Ben, 27
Lopez, Chloe, 45
Okafor, Ben, 27
Smith, Ana, 31
Lopez, Chloe, 45

This sorts text only. It does not understand quoted CSV fields that contain the separator.

Reverse, shuffle and remove duplicates

Reverse order flips the list without sorting it, handy for a log that should start with the newest entry. Shuffle reorders the lines at random using your browser's cryptographic random generator, so every order is equally likely. A shuffle changes every time you paste or change an option; to pick one random line only, use the spin the wheel. Remove duplicate lines keeps the first copy of each line; for the repeated lines themselves use remove duplicate lines.

With capitals respected, uppercase letters come before lowercase ones of the same letter:

b
Bb
A
ab
B
A
ab
B
b
Bb

Sorting dates, versions and mixed lists

Sorting is stable: lines that compare as equal keep the order you pasted them in.

Related tools

Sort lines FAQ

How do I sort lines alphabetically?

Paste the lines, one per line, and leave A to Z selected. The sorted list appears immediately; copy it or download it.

How do I sort numbers correctly?

Pick Numbers, low to high. The tool reads the first number in each line, including values such as 1,250 and 4.5, so 10 comes after 9. Lines without a number go last.

What is natural sort?

Natural sort treats digits inside text as numbers, so item2 comes before item10. Plain alphabetical sort would put item10 first. It is on by default and can be switched off.

Can I sort by the second word or column?

Yes. Enter the word number and choose the separator (spaces, commas, semicolons, tabs or pipes). The whole line is kept and the chosen field decides the order.

Is the shuffle fair?

Yes. It uses the browser's cryptographic random number generator with an unbiased shuffle, so every possible order is equally likely.

Does it handle accents and other alphabets?

Yes. Sorting follows your browser's language rules, so é sorts with e and ñ near n. Results can differ slightly between languages and devices.

Is my list uploaded anywhere?

No. Sorting happens in your browser, and nothing is sent to a server or stored.

Missing something in the sort lines?Suggest an idea. It takes 20 seconds and we read every one.Suggest an idea

Sends only what you type here, never the text you work with. Your email is used only to reply about this idea.

Free online tools