Text & Writing

Text Sorter — Sort Lines

Sort lines of text alphabetically, numerically or by length — with case-insensitive matching, trimming, de-duplication and reverse, all live.

  • Free forever
  • No sign-up
  • Runs in your browser
Share X LinkedIn

Your lines

Sort order

0
Lines in
0
Lines out
0
Removed

Sorted result

What is a text sorter?

A text sorter takes a list of lines and puts them in the order you want — alphabetical, numeric or by length — and cleans them up on the way. It's the fast answer to everyday list chores: alphabetising names, ordering keywords, tidying a CSV column, or de-duplicating a pasted export. You paste, pick an order, tick a couple of options, and copy the clean result. No formulas, no macros, no waiting.

How it works

The tool treats every line of your input as one item and processes them in a clear order:

  1. Trim (optional) removes leading and trailing whitespace from each line so stray spaces don't affect sorting or matching.
  2. Remove empty lines (optional) drops blank rows.
  3. Remove duplicate lines (optional) keeps only the first occurrence of each line.
  4. Sort reorders the remaining lines by the mode you chose:
    • A → Z / Z → A — alphabetical, using locale-aware comparison.
    • 0 → 9 / 9 → 0 — numeric, so 2 sorts before 10; non-numeric lines go to the end.
    • By length — shortest to longest, ties broken alphabetically.
  5. Reverse final order (optional) flips the whole list after sorting.

The case-insensitive toggle applies to both sorting and duplicate detection, so Apple and apple are treated as the same word. Everything updates live as you change the text or any option.

How to use it

  1. Paste your list into Your lines, one item per line.
  2. Pick a sort order — A → Z is the default.
  3. Turn on any options you need: case-insensitive, trim, remove duplicates, remove empty lines, or reverse.
  4. Read the sorted result in the output box and watch the counters for lines in, lines out and removed.
  5. Press Copy to put the clean list on your clipboard.

A worked example

Suppose you paste this messy list:

banana
Apple
apple
cherry

banana

With A → Z, case-insensitive, trim, remove duplicates and remove empty lines all on, the output becomes:

Apple
banana
cherry

Six lines in, three lines out, three removed — the blank line and the two duplicates (apple and the second banana) are gone, and the rest is alphabetised regardless of capitalisation.

If your only goal is stripping repeats, the Remove Duplicate Lines tool is a focused option; to measure the list you've just cleaned, the Word Counter reports characters, words and lines; and to normalise capitalisation before sorting, the Case Converter switches text to upper, lower, title or sentence case.

A note on how ties are handled

When two lines are equal for the chosen order — same first letter block, same number, or same length — they fall back to a plain alphabetical comparison, so the output stays stable and predictable. Numeric sorting reads the number at the start of each line, so 12 apples sorts as 12; lines with no leading number are grouped at the end rather than scattered through your numbers.

Private by design

All sorting happens in your browser with plain JavaScript. Your text is never uploaded, stored or shared — it stays on your device, which makes the tool safe for private lists, client data or anything you'd rather not send to a server. Explore more text and list tools on the all tools page.

Frequently asked questions

Comet's got your back

Stuck on something? Every tool has a short guide and FAQ — and Comet can point you to the right spot.

Visit help centre