Line Sorter

How to use 3 steps
  1. Paste your Lines.
  2. Choose Sort by and Direction, plus Case-insensitive or Drop blank lines.
  3. Press Sort, then Copy.
Sorted lines

Natural sort compares digit runs as numbers, so file2 comes before file10 rather than after it. Numeric sort reads the first number on each line and leaves lines without one at the end.

Loading the tool… 0 of 3 parts

Getting the tool ready. On a slow connection this can take a few seconds.

How this tool works

Sorting is locale-aware rather than a comparison of raw character values, so accented and non-Latin letters fall where a reader of that language expects instead of being pushed past Z. Five orderings are available: alphabetical, natural, numeric, by length, and a shuffle. The first four are stable orderings you can reverse; the shuffle is a Fisher-Yates pass over the list, which gives every arrangement an equal chance and ignores the direction setting entirely.

Natural order treats runs of digits inside a line as numbers, which is why it puts file2 before file10 where plain alphabetical order does not. Numeric order looks for the first number anywhere in each line — negative and decimal values included — and sorts on that, sending lines with no number in them to the end. Sorting by length compares character counts and breaks ties alphabetically so that equal-length lines still come out in a predictable order.

Picking an ordering that matches your data

  • Alphabetical is character order, not human order: anything with numbers in it — versions, filenames, invoice references — sorts by digit rather than by value. Natural order is the fix.
  • Numeric reads the first number it finds: a line beginning with a date or an identifier sorts on that number rather than the one you meant. Natural order is often the better choice for mixed lines.
  • Descending reverses after sorting: which also moves the lines that have no number in them from the end to the beginning.
  • The shuffle is genuinely random each run: run it twice and you get two different orders. Nothing about direction or case applies to it.

Alphabetical is wrong for numbered data

This is why a natural sort option exists, and it is the thing worth understanding.

A plain alphabetical sort compares character by character. That puts item10 before item2, because the character 1 comes before 2. Everything with a number in it comes out in an order nobody wants: version numbers, file names, chapter headings, invoice references.

A natural sort recognises runs of digits and compares them as numbers, so item2 precedes item10. The [msm_tool slug="sort-lines"] offers both because both are correct for different data.

Case decides only ties

The sort follows the alphabet first and letter case second, the way a dictionary does. apple and Apple end up next to each other — in most languages the lowercase one comes first — and Zebra still comes after both. Nothing jumps to the top just for starting with a capital.

Ticking the option to ignore case makes apple and Apple equal, so they stay in the order you pasted them. Natural order ignores case regardless.

Accented letters sort where your language puts them

The comparison is the browser's own language-aware one, in the language your browser is set to, rather than a comparison of raw character codes. So é sorts with e, and for an English reader Ångström sits among the A words instead of being pushed past Zulu.

It also means the order follows that language's rules, and those genuinely differ: Swedish puts Å after Z deliberately, German does not, and Spanish used to treat ll as a single letter. For a list meant for readers of another language, set the browser to that language before sorting, or check the result by hand.

Removing duplicates while sorting

Sorting groups identical lines together, which makes deduplication trivial — and the comparison is exact. A trailing space makes two visually identical lines different, and they will both survive.

If a deduplication leaves entries you were sure were duplicates, clean the whitespace first and sort again.

Blank lines and the header row

Two practical traps:

  1. Blank lines sort to the top in ascending order, because an empty string sorts before everything. Remove them first unless you want them there.
  2. A header row sorts with the data. Paste a list with a heading line and the heading ends up somewhere in the middle. Take it off first and put it back afterwards.

Reverse is not the opposite of natural

Reversing a natural sort gives you natural order descending, which is what you want. Reversing the lines of an already-sorted list also gives descending order for simple data and does not for anything where the sort was doing real work.

Use the descending option rather than sorting and then reversing.

What this is for

  • Tidying a list of names, tags, keywords or references into a readable order.
  • Finding duplicates in a list by grouping them together.
  • Preparing two lists for comparison — sorting both first means a diff shows genuine differences rather than ordering differences.
  • Making a long list scannable, which is the everyday case and the reason it exists.

Nothing is uploaded; the sort happens in your browser.

Frequently Asked Questions

Specific to the Line Sorter. Broader questions about this category are answered on the category page.

That is alphabetical order comparing characters, where 1 comes before 2. Switch to natural order to compare the digit runs as numbers.
At the end when ascending, and at the start when descending, since the whole list is reversed after sorting.
No. A shuffle has no direction — it rearranges the list at random every time it runs.
By default, comparison respects case. Tick the option to ignore it. Natural order compares without case regardless, by design.
No. Every line you pasted comes back, with identical ones adjacent. Removing them is a separate operation.

Subscribe to receive notifications about new tools, features, and productivity tips.