Skip to content

Sort lines

Paste a list with one item per line. The sorted result updates as you change the options, ready to copy.

Your list stays in this browser. Nothing is uploaded.
Sort
Remove
Compare
More options: columns, header, counts, line numbers
Sort by
Duplicates
Line numbers
Advertisement
Loose strips of paper being lined up in order, with two identical strips set aside

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".

One list, three ways to sort it
Character codes
  1. 10 tips
  2. 2 tips
  3. Banana
  4. File1.txt
  5. _notes
  6. apple
  7. file10.txt
  8. file2.txt
  9. zebra
A to Z, digits one by one
  1. _notes
  2. 10 tips
  3. 2 tips
  4. apple
  5. Banana
  6. File1.txt
  7. file10.txt
  8. file2.txt
  9. zebra
Natural order
  1. _notes
  2. 2 tips
  3. 10 tips
  4. apple
  5. Banana
  6. File1.txt
  7. file2.txt
  8. file10.txt
  9. 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.

The same ten cities in five alphabets
AlphabetSorted
EnglishAachen, Ängelholm, Åre, Cádiz, Chemnitz, Hamburg, Ibiza, Örebro, Oslo, Zürich
SwedishAachen, Cádiz, Chemnitz, Hamburg, Ibiza, Oslo, Zürich, Åre, Ängelholm, Örebro
DanishCádiz, Chemnitz, Hamburg, Ibiza, Oslo, Zürich, Ängelholm, Örebro, Aachen, Åre
CzechAachen, Ängelholm, Åre, Cádiz, Hamburg, Chemnitz, Ibiza, Örebro, Oslo, Zürich
TurkishAachen, Ä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.

The number the tool finds in each line
Line, smallest firstNumber found
-3 degrees-3
v2.5 beta2.5
Price $9.999.99
Chapter 1212
1,250 visitors1250
No number herenone, goes last
Advertisement

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.

Shuffling A, B and C 60,000 times
OrderFisher and YatesRandom 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

ProgramSortRemove duplicates
Microsoft WordSelect the list, then Home, Sort. Set Sort by to Paragraphs. Word for the web cannot sort.No built in option
ExcelData, then Sort A to ZData, Data Tools, Remove Duplicates
Linux and macOSsort -f sort -n sort -V sort -rsort -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

Frequently asked questions

How do I sort a list alphabetically?

Paste the list in the top box, one item per line. A to Z is on by default, so the sorted list is ready in the Result box. Click Copy result.

Can I sort a list and remove duplicates at the same time?

Yes. Tick "Duplicate lines" under Remove, and each line shows up once in the sorted result. Click "Keep order" to drop the copies without sorting. The remove duplicate lines tool does this by default and has more options.

Why does 10 come before 2 in other tools?

They compare one digit at a time, and "1" is smaller than "2". This tool reads whole numbers by default, so 2 comes before 10. Untick "Numbers in order" to get the old way.

Can I sort by the second column of a CSV file?

Yes. Open More options, set "Sort by" to a column and type 2. Tick "Keep the first line on top" if your file has a row of column names.

How do I count how many times each line appears?

Open More options and set Count to "show how often" or "most common first". Each line then shows up once, with its count in front.

Does it work with very long lists?

Yes. A list of 100,000 lines takes about one to three seconds on a normal computer. Long lists are sorted in the background, so the page does not freeze.

Is my list uploaded anywhere?

No. Sorting runs in your browser. The list is saved only in this browser, so it is still there after a reload.

  • Text editorWrite and edit plain text in your browser.
  • CSV editorOpen a CSV file in a grid, fix cells, sort, add or delete rows and save it as CSV, Excel, JSON or a Markdown table.
  • Case converterPaste text and change it to UPPERCASE, lowercase, Sentence case or Title Case in one click.
  • Word counterCount words, sentences and paragraphs as you type.
  • NotepadKeep several notes in one place.
  • Table editorOpen an Excel or OpenDocument file, or paste cells from a spreadsheet, and edit them in a grid.

↑ ↓ to choose, Enter to open, Esc to close