Skip to content
cliplimeClipLime

Sort lines of text

Alphabetical, natural, by number, by length or shuffled, with a switch for each detail.

0 characters, 0 lines

Lines in
0
Lines out
0
Empty lines removed
0
Duplicates removed
0
turned off

Sort options

Sorts as a dictionary does. 10 comes before 9, because 1 comes before 9.

Off treats Apple and apple as equal. On keeps them apart: capitals first in plain order, lower case first in language order.

Sorts letters the way the language does, so an accented letter sits next to its plain letter. Off sorts by plain Unicode order.

Languages order letters differently. In Swedish, a with two dots comes after z.

Sorts as if a leading dash, bullet or number such as 3. was not there. The lines keep it.

English only. The Great Gatsby sorts under G.

Removes spaces, tabs and other blank characters, such as non breaking spaces, at the start and end of every line first.

Drops lines that are empty or hold only spaces.

Keeps the first copy of each line. Case sensitivity above decides what counts as the same.

Your text stays in your browser. Nothing you type or paste is sent anywhere.

At a glance

Orders
A to Z or Z to A, natural order, by number, by length, reversed or shuffled.
Language rules
Follows a language's own letter order through your browser (Intl.Collator), or plain Unicode order if you switch that off. Pick a language such as Swedish or Spanish.
Natural order
item 2 comes before item 10, the way a file manager sorts. Version numbers such as 1.9 and 1.10 sort correctly too.
Cleaning
Trim lines, remove empty lines, remove duplicates, and ignore bullets, list numbers and a leading The, A or An.
Case
Ignored by default, so Banana and apple sort by their letters. Turn on Case sensitive to keep them apart.
Shuffle
A fair shuffle using your browser's secure random generator, with a button to shuffle again.
Privacy
Runs in your browser. Your lines are never uploaded.

How to do it

  1. 1

    Paste your lines

    Put one item on each line, or load a plain text file.

  2. 2

    Pick an order and a direction

    Alphabetical, Natural, By number, By length, Reverse or Shuffle. The direction buttons change their labels to suit the order.

  3. 3

    Set the options

    Case, language, bullets, articles, empty lines and duplicates are switches under the result.

  4. 4

    Copy or download

    The result updates as you change anything. Copy it, or download it as a text file.

Alphabetical, natural and by number

Three orders look alike and give different answers once numbers are involved. Take the lines item 1, item 10 and item 2:

  • Alphabetical compares character by character, like a dictionary. It puts item 1, item 10, item 2, because it compares one character at a time and 1 comes before 2.
  • Natural reads a run of digits as one number. It gives item 1, item 2, item 10, which is what a file manager does. It also puts version numbers in the right order: 1.9 comes before 1.10.
  • By number sorts on the first number found in each line, whether it is at the start or in the middle. It handles negative numbers, decimals with a dot, and thousands separators such as 1,200. Lines without a number go last, in their original order. It reads 1.10 as the decimal 1.1, so use Natural for versions.

Language rules and capital letters

With Follow language rules on, letters are ordered the way a language orders them. Switch it off and lines are compared by plain Unicode order, in which every capital letter comes before every small one and accented letters come after z. In that order Zebra sorts before apple, and éclair sorts after zebra.

  • English and most others: an accented letter sits next to its plain letter, so a, á and b come in that order.
  • Swedish: å, ä and ö come after z.
  • Danish: æ, ø and å come after z.
  • Spanish: ñ is a separate letter after n.
  • German: ä sorts with a, as in most dictionaries.
  • Turkish: the dotless ı and the dotted i are different letters with their own places.

Case sensitive is off by default. Then Apple and apple count as the same letters, and equal lines keep the order they had. Turn it on and capitals are told apart: in language order a comes before A, and in plain order every capital comes first.

Length, reverse and shuffle

By length sorts on the number of characters in each line. Characters are Unicode code points, not bytes, so an accented letter stored as one character (é) counts once, while a letter followed by a separate accent mark counts twice. Lines of the same length keep their original order. Reverse flips the order, so the last line comes first. It is the quick way to turn a log that has its newest line at the bottom upside down.

Shuffle puts the lines in a random order using the Fisher-Yates method with your browser's secure random number generator, so every order is equally likely. Press Shuffle again for a new one. It is good for a speaking order, a playlist or a set of flashcards. It is not a verifiable draw, so do not use it where people need to be able to check the result.

Cleaning the list while you sort

  • Trim spaces around each line stops stray spaces from changing the order. A line with a leading space would otherwise sort before the others.
  • Remove empty lines drops blank lines, so they do not collect at the top.
  • Remove duplicate lines keeps the first copy of each. Case sensitivity decides what counts as the same. For counts and more control, use the duplicate line remover.
  • Ignore bullets and list numbers sorts as if a leading dash, bullet or number such as 3. was not there. The lines keep it.
  • Ignore a leading The, A or An files The Great Gatsby under G, as libraries and indexes do. It is for English only.

The sort is stable: lines that compare as equal keep the order they had. For a plain A to Z list with the list friendly defaults already set, open alphabetize a list.

Questions people ask

How do I sort lines in alphabetical order?

Paste the lines into the box and leave Alphabetical and A to Z selected. The sorted lines appear next to it, and Copy puts them on your clipboard.

Why does 10 come before 2?

Alphabetical order compares character by character, and 1 comes before 2, so 10 sorts before 2. Choose Natural to read the digits as a number, or By number to sort by the first number in each line.

Does sorting ignore capital letters?

Yes, by default. Apple and apple sort by their letters and equal lines keep the order they had. Turn on Case sensitive to tell them apart.

How do I sort a list of numbers?

Choose By number for a list of plain numbers or lines that contain one. It handles negatives, decimals with a dot and thousands separators. Lines without a number go to the end.

Is the shuffle really random?

It uses your browser's secure random number generator with a fair shuffling method, so every order is equally likely. It is good for everyday use, but it cannot be checked by someone else, so it is not a substitute for a verifiable draw.

Is my text uploaded?

No. Sorting runs in your browser. Nothing you paste or load is sent anywhere.

Guides that help

All Text guides →