Skip to main content
Text & Writing Tools

Sort Lines

Sort lines of text alphabetically, in natural or numeric order, by length, in reverse or at random, with optional duplicate removal.

Paste your lines and pick an order - the sorted list updates instantly.

Alphabetical order depends on language rules; this tool uses your browser's sorting, which handles accents the way most people expect.

What Is the Sort Lines Tool?

It puts lines of text in order: alphabetically, in natural order, by the number in each line, by length, reversed or shuffled at random. Empty lines and duplicates can be removed in the same step.

Which Order to Choose

  • Alphabetical - names, words and tags.
  • Natural order - file names and versions, so chapter2 comes before chapter10.
  • Number - lines such as prices, scores or "12 apples", sorted by the first number in each line.
  • Length - spotting the shortest or longest entries.
  • Random shuffle - quiz questions, running orders or a fair turn order.

How to Use It

  1. Paste your lines.
  2. Choose the order. The sorted result updates immediately.
  3. Tick the options you want and copy or download the result.

Example

The file names chapter10.txt, chapter2.txt, Chapter1.txt, chapter21.txt, chapter3.txt sorted alphabetically come out as chapter1, chapter10, chapter2, chapter21, chapter3 - because "1" sorts before "2" character by character. With Natural order they come out the way a person expects: Chapter1.txt, chapter2.txt, chapter3.txt, chapter10.txt, chapter21.txt.

Upper and Lower Case

By default, capital and small letters are sorted together, so apple and Apple sit side by side. Tick Case-sensitive to sort by exact character codes instead, which puts all capitalised lines first - the way many programming languages sort.

Limitations

Alphabetical order follows your browser's language rules, which handle accented letters well but may differ slightly from a dictionary in your language. Number sorting reads only the first number in each line, and lines without a number go to the end. To remove repeats without sorting, use Remove Duplicate Lines; to pick one line at random, use the Random Picker.

Frequently Asked Questions

Natural order treats numbers inside text as numbers, so file2 comes before file10. A plain alphabetical sort compares character by character and puts file10 before file2.

The tool reads the first number in each line, including negative numbers and decimals, and sorts by it. Lines without a number are placed at the end.

Not by default - capital and small letters are sorted together. Tick Case-sensitive to sort by character code, which puts capitalised lines before lowercase ones.

Yes. Shuffling uses the Fisher-Yates method with your browser's cryptographic random number generator, so every order is equally likely.
Share this tool: