All tools · Text tools

Sort Lines

Sort lines alphabetically, numerically, or by length.

Free to use, no sign-up required. Sort Lines is one of 198 tools built into Xenition, alongside a chat that can use them for you.

Sorts a list of lines alphabetically, in reverse, by the number at the start of each line, or by length, and can remove exact duplicates at the same time.

How to use Sort Lines

  1. Paste the list into the box, one item per line.
  2. Pick A→Z, Z→A, 0→9 or Length.
  3. Tick unique to drop exact duplicate lines.
  4. Copy the sorted list.

How it works

A→Z and Z→A use the browser’s localeCompare, which sorts in dictionary order for your language and puts lowercase and capital versions of a letter next to each other. 0→9 reads the number at the start of each line with parseFloat; a line that does not start with a number counts as 0. Length sorts from shortest to longest. Lines that tie keep their original order. unique removes lines that match exactly, including case and spaces.

Example

A→Z sorts 10, 9, 100, 2.5 as 10, 100, 2.5, 9, while 0→9 gives 2.5, 9, 10, 100.

Questions about Sort Lines

Why does item10 come before item2?

A→Z compares text character by character, and 1 comes before 2. 0→9 does not help here either, because the lines start with letters and all count as 0.

Where do blank lines end up?

An empty line sorts first in A→Z and Length and last in Z→A. With unique ticked, several blank lines collapse into one.

Use it from chat

You do not have to open Sort Lines to use it. Ask Xenition in plain language and it runs the right tool, then carries the answer into whatever you are working on — a document, a spreadsheet, a deck.

Related tools