How the Text Sorter works
Alphabetical sorting uses your browser's language rules (Intl.Collator), so accented letters
sort next to their base letter (é with e) instead of after z. With
Natural sort ticked, runs of digits are compared as numbers, so item2 comes before
item10. Upper and lower case are treated as equal unless you tick Case sensitive.
Numeric sorting uses the first number found in each line, including negative numbers, decimals,
thousands separators such as 1,250.5 and exponents such as 2e3. Lines without a number keep
their order and go to the end, in both ascending and descending order. Line length counts characters
as they appear on screen, so an emoji counts as one.
All sorts are stable: lines that compare as equal stay in their original order. Reverse simply flips
the order of the lines. Shuffle uses the Fisher–Yates algorithm with random numbers from
crypto.getRandomValues, so every order is equally likely. Duplicate removal runs after sorting and keeps the
first copy of each line; it ignores case unless Case sensitive is ticked.
How to use the Text Sorter
- Paste your list into the Lines to sort box, one item per line, open a text file, or select Load example.
- Choose Sort by (alphabetical, numeric, line length, reverse or shuffle) and the Order (ascending or descending).
- Set the options: Natural sort, Case sensitive, Remove duplicate lines and Remove empty lines.
- Select Sort lines or press Ctrl + Enter, then copy the result or download it as a .txt file.
Example
These lines:
item10
Banana
item2
apple
item1
sorted alphabetically with natural sort become:
apple
Banana
item1
item2
item10
Without natural sort, item10 would come before item2, because the character 1 sorts before 2.
Common use cases
- Putting a list of names, tags or glossary terms in alphabetical order.
- Ordering file names or version numbers such as v2 and v10 the way people expect.
- Sorting lines of a report by the amount or score they contain.
- Shuffling a list of participants, questions or playlist items into a random order.
Common errors and how to fix them
- Numbers sort in the wrong order, such as 10 before 2
- The default comparison reads text character by character, and the character 1 comes before 2. Switch to the numeric sort mode.
- All capitalised lines group before the lowercase ones
- A case-sensitive sort places uppercase letters first. Turn on case-insensitive sorting for the order you probably expect.
- Lines that look identical do not end up together
- One of them carries trailing whitespace or a different line ending. Run the text through Remove Extra Spaces or the Line Break Formatter first, then sort.
- Shuffling needs secure random numbers, which this browser does not provide
- The shuffle option uses the Web Crypto API rather than a weaker random source. Update your browser, or load the page over HTTPS.
Frequently asked questions
What is natural sort?
Natural sort compares runs of digits as whole numbers, so item2 comes before item10 and file9.txt before file10.txt. Without it, text is compared character by character and item10 comes first because 1 sorts before 2.
How does alphabetical sorting handle accents and case?
It uses your browser's language-aware comparison (Intl.Collator), so é sorts next to e rather than after z. Upper and lower case are treated as equal, keeping their original order, unless you tick Case sensitive, which then also puts lower-case words before capitalized ones when the letters are the same.
How does numeric sorting work?
Each line is sorted by the first number in it. Negative numbers, decimals, thousands separators such as 1,250.5 and exponents such as 2e3 are understood. A hyphen directly after a letter or digit is not treated as a minus sign, so item-5 is read as 5. Lines without a number are placed at the end in their original order.
Is the shuffle really random?
Yes. Shuffle uses the Fisher–Yates algorithm with random numbers from your browser's cryptographic random number generator (crypto.getRandomValues), without bias, so every possible order is equally likely.
Is the sort stable?
Yes. Lines that compare as equal, such as the same word in different case, stay in the order they had in your input, in both ascending and descending order.
Is my text uploaded?
No. Sorting runs in your browser and your text is not sent to our server.