Skip to content

Sort Lines

Sort any list of lines A-Z, Z-A, by length, or randomise - case-aware, in your browser.

Runs in your browser

Paste a list, pick an order, get the sorted output. Five orders: alphabetical A to Z, Z to A, by length (short first), by length (long first), and random shuffle. Locale-aware comparison handles accents and natural number ordering correctly.

How to use it

  1. Paste your text

    One entry per line. Empty lines are kept or dropped per the option.

  2. Pick a sort order

    A-Z, Z-A, by length (short or long), or random.

  3. Copy the sorted list

    Output appears in the right pane. Hit Copy to grab it all.

What is it?

A line sorter takes a text input and re-orders its lines by a chosen comparison: lexicographic, length, or random. The interesting choices are around stability (lines with equal keys keep their input order), locale (so 'café' sorts properly), and natural ordering (so 'page-2' beats 'page-10').

When to use it

Organising a list of names, emails, slugs or URLs before sharing or importing. Building an A-Z reference page from a notes dump. Shuffling a playlist or class roster when you need a random order. Putting a CSV's header line aside, then sorting the body, then pasting them back together.

Common mistakes

Sorting a CSV with a header row included - the header lands somewhere alphabetical and the file no longer parses. Forgetting that 'page-10' beats 'page-2' in pure-ASCII sort but not in natural sort. And using ascending order to mean 'oldest first' when the lines are dates in YYYY-MM-DD - that's already alphabetical-by-date, so ascending is oldest, descending is newest.

FAQ

Is the sort stable?
Yes. Lines that compare equal keep their relative input order. Important when you're sorting by length and want the original sequence preserved within each length bucket.
Does it handle numbers naturally?
Yes. 'item-2' sorts before 'item-10' using JavaScript's Intl-aware comparison; if you want pure ASCII order ('item-10' first), turn off natural ordering.
What about case?
Case-insensitive by default. Toggle case-sensitive to put all uppercase before lowercase ('A' before 'a').

More in this category