Sort Lines

Paste a list, one item per line, and pick the order you want. The sorted list appears as you type, with a count of the lines that moved.

How it works

The default A to Z order compares the numbers inside a line by their value, so "item 2" comes before "item 10". Capital and small letters sort together, and accented letters sit next to their plain ones, as in a dictionary.

The number sort reads the first number on each line, with commas, decimals and minus signs, so "1,200" counts as one thousand two hundred. Lines with no number at all go to the end in the order they were in.

The length sort counts characters, not bytes, so an accented letter such as é counts as one. Lines that tie keep the order they had. The sort runs on this page, and nothing you paste is sent anywhere.

How to use it

  1. 1 Paste your list into the Text box, one item per line.
  2. 2 Pick an Order, such as A to Z, By number, smallest first, or Longest line first.
  3. 3 Turn on Remove duplicates or Drop blank lines if you want those gone too.
  4. 4 Copy the result, or download it as a .txt file.

Good to know

  • If "item 10" lands before "item 2", you have the character-by-character order selected. Switch back to A to Z.
  • A list of prices sorts best by number, because "$9" and "$10" then compare as 9 and 10.
  • Blank lines sort to the top of an A to Z list. Drop blank lines keeps them out of the way.
  • Reverse the current order flips the list without sorting it, which is handy for a log that is newest last.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Sorting a list of file names so that file 10 comes after file 9

Take a folder of exported photos: IMG 1.jpg, IMG 2.jpg and so on up to IMG 12.jpg. Paste the names into most sort tools and you get IMG 1, IMG 10, IMG 11, IMG 12, IMG 2, IMG 3. The tool is not broken. It compares the names one character at a time, and the character "1" comes before "2", so every name that starts with IMG 1 lands before IMG 2.

People do not read numbers that way. A run of digits is one number, and 10 is bigger than 2. The default A to Z order here works the same way: when two lines reach digits at the same place, it compares the whole numbers. The photo list comes back as IMG 1, IMG 2, IMG 3 and on to IMG 12, which is the order a camera took them in. This is often called a natural sort.

A different job is sorting by the number itself. Paste a price list such as "Tea $4.50", "Cake $12", "Coffee $3" and pick By number, smallest first. The tool reads the first number on each line, so the list becomes Coffee, Tea, Cake. Commas inside a number are read as thousands, so "1,200 visits" sorts as 1200. A line with no number, such as a heading, goes to the end rather than being treated as zero.

Sorting by length helps with less obvious jobs. Longest line first puts the longest names in a list at the top, which shows what will not fit a column or a label. Shortest line first is a quick way to find stray one-letter lines left over from a bad copy and paste. With Remove duplicates on, the list is cleaned and sorted in one step, and the note under the result says how many lines went.

The tool has limits. The A to Z order follows English dictionary rules, so it will not match the order of a language with different rules, such as Swedish, where å comes after z. It reads only the first number on a line, so "2 of 10" sorts by the 2. It takes up to 1 MB of text at a time. Above that, split the file and sort each part.

Frequently asked questions

Why does "item 10" come after "item 9" here and before it in some other tools?

Many tools compare text one character at a time, and "1" comes before "9", so "item 10" lands first. This tool reads runs of digits as whole numbers in the default A to Z order. The character-by-character order is still in the list if you need it.

Does the sort care about capital letters?

Only to break a tie. "apple", "Apple" and "banana" sort as apple, Apple, banana, so words that differ only in case stay next to each other.

What happens to lines without a number when I sort by number?

They go after all the numbered lines, in the order they were in, whichever direction you sort. They are never mixed in as zero.

Is there a size limit?

Up to 1 MB of text at a time, which is tens of thousands of lines. The sort runs as you type, and the limit keeps it fast on a phone. Split a bigger file into parts.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.