Sort Lines
Put a list in alphabetical, natural, length or random order without leaving the page.
- lines
- 1
Output
Paste or type above to see the result here.
Your files stay on your device
This tool runs entirely in your browser. What you paste is processed on your device and is never sent to a server, so it is safe to use with tokens, keys and unpublished text.
Example
Example: lecture recordings 1 to 20 in the right order with Natural sort
A student pastes the file names of a course’s recordings to make a playlist. Ignore case is on, as it is by default, and Remove duplicate lines is ticked, because one file was saved twice in lower case. Then A to Z, and Natural, for comparison.
- A to Z compares character by character: “10” starts with a 1, which comes before 2, so lectures 10, 11 and 20 jump ahead of 2 and 3.
- Natural compares each run of digits by its value: 1, 2, 3, 10, 11, 20.
- With Ignore case on, “lecture 2 - cells.mp4” is the same line as “Lecture 2 - Cells.mp4”: the first one pasted stays, and the count drops from 7 lines to 6.
| Pasted | A to Z | Natural (2 before 10) |
|---|---|---|
| Lecture 10 - Revision.mp4 | Lecture 1 - Introduction.mp4 | Lecture 1 - Introduction.mp4 |
| Lecture 2 - Cells.mp4 | Lecture 10 - Revision.mp4 | Lecture 2 - Cells.mp4 |
| Lecture 1 - Introduction.mp4 | Lecture 11 - Exam tips.mp4 | Lecture 3 - Enzymes.mp4 |
| Lecture 11 - Exam tips.mp4 | Lecture 2 - Cells.mp4 | Lecture 10 - Revision.mp4 |
| lecture 2 - cells.mp4 | Lecture 20 - Genetics.mp4 | Lecture 11 - Exam tips.mp4 |
| Lecture 3 - Enzymes.mp4 | Lecture 3 - Enzymes.mp4 | Lecture 20 - Genetics.mp4 |
| Lecture 20 - Genetics.mp4 |
Six lines from Lecture 1 to Lecture 20, ready for a playlist or a list of links. Natural order works the same for chapter numbers, invoice numbers and photo names such as IMG_9 and IMG_10.
How it works
- Paste the lines you want to sort, one item per line.
- Choose the order. A to Z and Z to A are plain alphabetical; Natural sorts numbers inside text by value so item2 comes before item10; By length sorts shortest to longest.
- Turn on Ignore case so that apple and Banana sort together regardless of capitalisation, and Remove duplicates if you also want a unique list.
- The result appears as you type; copy it. Reverse and Shuffle ignore alphabetical order and simply flip or randomise the current sequence.
Frequently asked questions
- What is natural sort order?
- Natural order compares runs of digits by numeric value instead of character by character, so file1, file2, file10 come out in that order rather than file1, file10, file2. It is what you want for file names, version numbers and numbered lists.
- How are accented and non-English characters sorted?
- Sorting follows the rules of the page’s language (Intl.Collator in English), not your browser’s settings, so é sorts next to e. Japanese kana come in gojūon order, hiragana and katakana together; kanji follow their code points, not their reading. Results can differ slightly between browsers.
- Is the sort stable?
- Yes. Lines that compare as equal, for example with Ignore case on, keep their original relative order. Sorting by length puts lines of the same length in alphabetical order.
- How random is Shuffle?
- Shuffle uses a Fisher-Yates shuffle with the browser's cryptographic random source, so every permutation is equally likely. It is suitable for picking a random order for names or questions.
- Why does 10 come before 2?
- A to Z compares text character by character, and “1” sorts before “2”, so “10” lands ahead of “2”. Choose Natural (2 before 10) to sort the numbers inside lines by their value.
- What happens to empty lines?
- They are kept: A to Z puts them at the top and Z to A at the bottom. Remove duplicate lines leaves just one of them; to drop them all, run the list through Remove Duplicate Lines, which skips empty lines by default.
- Is my list sent to a server?
- No. Sorting runs entirely in your browser. Nothing is uploaded or logged.
Related tools
• Remove Duplicate Lines Paste a list and keep only the first occurrence of each line, in the order you pasted it. • Word Counter Live word, character, sentence and paragraph counts for essays, posts, ads and anything with a length limit. • Case Converter Switch between UPPER, lower, Title, Sentence, camel, Pascal, snake and kebab case in one click. ≠ Text Diff Paste two versions of a text and see exactly which lines changed.