Shard Tools

Sort Lines

Sort lines of text alphabetically in your browser, with natural numeric ordering and a reverse option.

Maintained by Roshan.

Use Sort Lines

Converts lines to sorted in this tab, with nothing sent anywhere.

Runs entirely on your deviceThe conversion happens in this browser tab. Nothing you type is uploaded, logged or stored, which is worth knowing for anything you would not paste into a search box.

Explore text tools

Find related browser-local tools for nearby tasks without starting another search.

Browse all text tools

About Sort Lines

Putting a list in order is a small task that comes up endlessly - arranging names, tidying a list of imports, ordering entries before a review, making two lists comparable by sorting both. Doing it by hand past a dozen items is tedious and mistake-prone. The detail that separates a good sort from a frustrating one is how numbers are handled. A plain alphabetical sort puts item10 before item2, because it compares character by character and 1 comes before 2, which is almost never what a person wants. This tool sorts in natural order, so item2 comes before item10 the way you would expect, and it ignores case so that a capitalised entry is not banished to the top or bottom away from its lowercase neighbours. A reverse option flips the order.

Work through the input

  1. Each line is treated as one item, and the lines are ordered by comparing them.
  2. The comparison is natural: embedded numbers are compared by value, so item2 sorts before item10 rather than after it.
  3. Case is ignored, so Apple and apple sort together rather than all capitals being grouped away from lowercase.
  4. A reverse option produces descending order, from Z to A, when that is what you need.
  5. Blank lines and the line structure are preserved as items in the sort.

When sort lines is useful

Alphabetising a list of names

Paste the names and sort. Natural ordering keeps any numbered entries in sensible order too.

Comparing two lists

Sort both lists the same way and differences line up, making them easy to compare side by side.

Check the output

Questions about Sort Lines

Why does item10 come after item2 here?

Because the sort is natural - it compares embedded numbers by value. A plain character sort would wrongly put item10 first.

Is it case sensitive?

No. Case is ignored for ordering, so mixed-case entries sort together. The original case is kept in the output.

Can I sort Z to A?

Yes. The reverse option produces descending order.

Can it sort by a column?

It sorts whole lines. For column sorting, split the data or use a spreadsheet.

Related tools

Remove Duplicate Lines

Remove duplicate lines from text in your browser, keeping the first occurrence and the original order.

Remove Line Breaks

Remove line breaks from text in your browser, collapsing it into a single line without merging words.

Reverse Text

Reverse text in your browser, correctly handling emoji and accented characters.