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.

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 sensitivity changes the order

A case-sensitive sort puts all capitals before all lowercase, because that is their order in the character set. So Zebra comes before apple, which looks like a bug and is not.

For a list of names, titles or anything a person will read, a case-insensitive sort is almost always what you want. For sorting identifiers or code, case sensitivity may matter.

Accented characters sort after Z

A simple sort orders by code point, and accented Latin characters sit above the plain A–Z range. So Ångström lands after Zulu rather than at the beginning where a Swedish reader would expect it — and a French reader would expect é to sort with e, which it does not.

Proper alphabetical ordering is language-specific and genuinely complicated: Swedish puts Å after Z deliberately, German does not, and Spanish used to treat ll as a single letter. A code-point sort is predictable rather than linguistically correct, and for a list anyone will read in a specific language, expect to adjust it 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.