How to use the Sort Lines
- Paste your list into the left box, one item per line.
- Choose how to sort: Alphabetical, Natural (so 2 comes before 10), Numeric, Length, Reverse order or Shuffle.
- Pick a direction and tick any clean-up options, such as removing duplicates.
- Copy the sorted list, or click Sort again / reshuffle for a new random order.
Features
- Alphabetical, natural, numeric and length sorting, ascending or descending
- Reverse the current order without sorting
- Fair random shuffle powered by your browser’s cryptographic random generator
- Language-aware ordering, so accented letters sort where readers expect
- Optional case-insensitive sorting, duplicate removal and blank line removal
- Stable sorting: equal lines keep their original relative order
Choosing the right kind of sort
“Sort A to Z” sounds simple until numbers and capital letters are involved. Here is how the same list comes out with each method:
| Input | Alphabetical | Natural | Length |
|---|---|---|---|
| file10.txt | apple.txt | apple.txt | file2.txt |
| file2.txt | File1.txt | File1.txt | File1.txt |
| File1.txt | file10.txt | file2.txt | apple.txt |
| apple.txt | file2.txt | file10.txt | file10.txt |
Alphabetical compares text character by character, so “file10” lands before “file2” because the character 1 comes before 2. Natural sorting reads runs of digits as whole numbers, giving the order a person would expect for file names, chapters and version numbers. Length orders lines by how many characters they have, keeping the original order for lines of equal length.
Numeric sorting
Numeric mode finds the first number in each line and sorts by its value. It understands negative numbers, decimals and thousands separators, so “-3.5 °C”, “$1,200” and “Item 7” are compared as -3.5, 1200 and 7. Lines without any number are placed at the end, still in their original order. Use it for price lists, scores, measurements and anything else where the number is the point.
Upper and lower case
With Ignore upper/lower case on, “apple”, “Banana” and “cherry” sort the way a dictionary would. Turn it off for strict character-code order, where every capital letter comes before every lowercase letter, so “Zebra” sorts above “apple”. Programmers sometimes need that order to match how a program compares strings.
Alphabetical and natural sorting use your browser’s language rules, so accented letters such as é and ü are sorted next to e and u rather than after z.
Reverse and shuffle
Reverse order flips the list exactly as it is, without sorting, which is handy for turning an oldest-first log into newest-first. Shuffle uses the Fisher–Yates algorithm with random numbers from your browser’s Web Crypto API, so every possible order is equally likely. That makes it suitable for picking a running order for presentations, randomizing quiz questions or drawing names. For a visual draw, try the Spin the Wheel tool.
Cleaning while you sort
The clean-up options run before sorting: spaces are trimmed from line ends, empty lines are removed, and duplicates are dropped so each item appears once. Trimming matters more than it seems, because a line that starts with a space sorts before all the letters. For deduplication without changing the order, use Remove Duplicate Lines instead.
Frequently asked questions
Why does 10 come before 2 when I sort?
Alphabetical sorting compares characters one at a time, and “1” comes before “2”. Choose Natural or Numeric to sort numbers by their value.
Is the shuffle really random?
Yes. It uses the Fisher–Yates shuffle with random numbers from your browser’s cryptographic generator, so every order is equally likely. Click “Sort again / reshuffle” for a new order.
What happens to lines that are equal?
The sort is stable: lines that compare as equal stay in the same order they had in your input, in both directions.
Can I reverse a list without sorting it?
Yes. Choose Reverse order to flip the lines exactly as they are, last line first.
Does it sort non-English text correctly?
Alphabetical and natural modes use your browser’s built-in language rules, which handle accented letters and most alphabets sensibly.