Skip to content
All tools
English

Sort lines

Alphabetical order that gets Arabic, accents and numbers right, plus shuffle, reverse and line numbering.

Your files never leave your device

Type, paste or drop a .txt file. Everything stays on this device.

Words
0
Characters
0
Without spaces
0
Lines
0
Sentences
0
Reading time
0
Options
Add to each line

How to use it

  1. Paste your text

    Type, paste, or drop a .txt file into the editor. Long documents are fine.

  2. Pick an order and sort

    A to Z, Z to A, natural, by length, reversed or random. Empty lines are dropped unless you keep them.

  3. Copy or download

    Copy the result, download it as a .txt file, or press Undo to go back a step.

Alphabetical is harder than it looks

A simple computer sort compares character codes, so Zebra comes before apple and Éclair lands after z. This tool uses your browser's language-aware collation (the Unicode Collation Algorithm), so upper and lower case sort together, accented letters sit next to their base letter, and Arabic follows the order of the Arabic alphabet, with أ and إ next to ا.

Natural order

In plain alphabetical order, file 10 comes before file 2 because the character 1 is smaller than 2. Natural order reads the numbers as numbers: file 1, file 2, file 10. Use it for chapters, file names, invoice numbers and versions.

Other orders

  • By length: shortest first (or longest first), ties broken alphabetically. Handy for finding the longest titles or keywords.
  • Reverse: flips the current order, last line first, without sorting.
  • Shuffle: a fair random order (Fisher–Yates), for drawing names, quiz questions or test data.

Add to each line and number lines

"Add to each line" puts text before and after every non-empty line, for example quotes and a comma to turn a list into SQL 'a', values, or - to make a Markdown list. "Number lines" adds 1., 2., 3. Duplicates in the list? Remove them first; lines broken across rows? Join them.

Frequently asked questions

Why is "apple" next to "Apple" instead of after all capitals?
Case-insensitive sorting is on by default because that is what people expect. Turn off "Ignore case" to put upper-case lines before lower-case ones when they are otherwise equal.
How does it sort Arabic?
By the Arabic alphabet (ا ب ت ث …), using your browser's Arabic collation. Hamza forms of alef sort with alef, and tashkeel does not change the order.
Is the shuffle really random?
It uses the Fisher–Yates algorithm with your browser's random number generator, so every order is equally likely. It is fine for classroom draws, not for lotteries with legal requirements.