
Last checked by the TextEditor.com team
Why file10 can come before file2
A computer compares text one character at a time. In "file10" and "file2" the first four letters match. Then it compares "1" with "2", and "1" is smaller, so file10 wins. The length of the number does not matter.
Natural sort order reads a run of digits as one number. Then 2 comes before 10, the way a person would put them. This tool uses natural order unless you turn off "Numbers in order". Plain character code order is worse still: every capital letter comes before every small letter, so "Banana" lands before "apple".
- 10 tips
- 2 tips
- Banana
- File1.txt
- _notes
- apple
- file10.txt
- file2.txt
- zebra
- _notes
- 10 tips
- 2 tips
- apple
- Banana
- File1.txt
- file10.txt
- file2.txt
- zebra
- _notes
- 2 tips
- 10 tips
- apple
- Banana
- File1.txt
- file2.txt
- file10.txt
- zebra
Character codes is the order of a plain JS sort and of old programs. The middle column ignores case but still reads digits one by one.
Each language has its own A to Z
Letters with marks do not sort the same way everywhere. In German, ä sorts like a. In Swedish, å, ä and ö are letters of their own that come after z. Danish treats "aa" as the letter å, so Aachen moves to the very end. Czech puts "ch" after h.
Pick your language under "Alphabet" and the tool follows its rules. The rules come from your browser, which uses the Unicode collation data from the CLDR project.
| Alphabet | Sorted |
|---|---|
| English | Aachen, Ängelholm, Åre, Cádiz, Chemnitz, Hamburg, Ibiza, Örebro, Oslo, Zürich |
| Swedish | Aachen, Cádiz, Chemnitz, Hamburg, Ibiza, Oslo, Zürich, Åre, Ängelholm, Örebro |
| Danish | Cádiz, Chemnitz, Hamburg, Ibiza, Oslo, Zürich, Ängelholm, Örebro, Aachen, Åre |
| Czech | Aachen, Ängelholm, Åre, Cádiz, Hamburg, Chemnitz, Ibiza, Örebro, Oslo, Zürich |
| Turkish | Aachen, Ängelholm, Åre, Cádiz, Chemnitz, Hamburg, Ibiza, Oslo, Örebro, Zürich |
Sorting by number
"By number" looks for the first number in each line and sorts by its value. It reads minus signs, decimal points and thousands commas, so "1,250" counts as one thousand two hundred fifty. Text around the number, like a $ sign or a word, does not get in the way.
Lines with no number at all go to the end, in A to Z order. Tick "Largest first" to turn the order around.
| Line, smallest first | Number found |
|---|---|
| -3 degrees | -3 |
| v2.5 beta | 2.5 |
| Price $9.99 | 9.99 |
| Chapter 12 | 12 |
| 1,250 visitors | 1250 |
| No number here | none, goes last |
Duplicate lines and counts
Tick "Duplicate lines" under Remove to keep one copy of each line. With "Match case" off, Apple and apple count as the same line. Set "Count" under More options to put how often each line shows up in front of it, or pick "most common first" to rank the lines. For more ways to find copies, like ignoring invisible characters or seeing which lines were removed, use remove duplicate lines.
Sort a table by one column
Each line of a CSV file is a row, with the values split by commas. Under More options, set "Sort by" to a column and give its number. The tool finds the separator by itself: a tab, a semicolon, a comma or a bar. Values in double quotes may hold commas of their own.
Turn on "Keep the first line on top" so the row of column names stays where it is. "A word" works the same way for plain text, with spaces between the words. For bigger tables with many columns, the CSV editor shows them as a grid.
A fair shuffle
Shuffle uses the Fisher and Yates method with random numbers from your browser's crypto API. Every order of the lines is equally likely.
A popular shortcut is to sort with a random compare. It looks random, but it is not fair. Some orders come up far more often than others, and the result depends on the browser. Run both methods below and compare the bars.
| Order | Fisher and Yates | Random compare |
|---|---|---|
| ABC | 10,049 | 14,996 |
| ACB | 10,228 | 7,491 |
| BAC | 9,945 | 14,939 |
| BCA | 9,913 | 7,563 |
| CAB | 10,027 | 7,489 |
| CBA | 9,838 | 7,522 |
One run in Microsoft Edge, November 2026. A fair method gives each order about 10,000 times.
Sorting in Word, Excel and on the command line
| Program | Sort | Remove duplicates |
|---|---|---|
| Microsoft Word | Select the list, then Home, Sort. Set Sort by to Paragraphs. Word for the web cannot sort. | No built in option |
| Excel | Data, then Sort A to Z | Data, Data Tools, Remove Duplicates |
| Linux and macOS | sort -f sort -n sort -V sort -r | sort -u or sort | uniq -c |
On the command line, -f ignores case, -n sorts by number, -V gives natural order and -r reverses it. sort -R is not a true shuffle, because it keeps identical lines together. The shuf command shuffles fairly. Checked in the Microsoft support pages and the GNU sort manual, November 2026.
More tools for lines
- Remove repeated linesa a b → a bKeeps the first copy of each line and drops the rest.
- Clean up pasted texta b → a bThe text cleaner removes extra spaces and hidden characters.
- Replace a word everywherecolour → colorFind and replace, with match case and regex patterns.
- Compare two textsthe
oldnew catText compare marks what was added and what was removed.