Skip to content

Sort Lines, Reverse & Shuffle Text

Sort lines A–Z, naturally or by length, reverse or shuffle. Runs in your browser.

Loading tool…

About this sort lines, reverse & shuffle text

This tool sorts, reverses or shuffles the lines of any list you paste. It's for anyone who works with lists: a teacher ordering a class roster by surname, a developer sorting config keys, or an organizer who needs a fair random order for a raffle.

Paste one item per line and the result appears as you type. You can sort A to Z or Z to A, put numbers in their real order, sort by length or by the last word, and clean the list in the same pass by trimming spaces and dropping duplicates and empty lines.

Everything runs in your browser. Your list is never uploaded, and there are no daily limits or wait timers.

Features

  • Five ways to sort

    Alphabetical, Natural, Numeric, Length and Last word. The order switch changes its labels to fit the mode: A → Z, Low → High or Short → Long.

  • Numbers in the right order

    Natural puts item 2 before item 10. Numeric reads the first number on each line, so -5, 3.2, 10 and 1,200 land in true value order.

  • Surnames and titles

    Last word sorts full names by family name. Ignore "The", "A", "An" files The Zebra Room under Z, the way a library catalog does.

  • Reverse without breaking characters

    Reverse the line order, the whole text, the letters in each line, or the word order in each line. Emoji like 👍🏽 and flags like 🇯🇵 stay whole.

  • A shuffle you can trust

    Fisher–Yates with your browser's cryptographic random generator. Press Shuffle again or Ctrl+Enter for a new order.

  • Cleanup and counts

    Trim spaces, remove empty lines and remove duplicates, with or without matching case. Tiles show lines in, lines out and how many were removed.

  • Files and big lists

    Open a .txt, .csv or .log file and download the result as .txt. Windows line endings are kept. Over 25,000 lines, the result waits for Apply so typing stays smooth.

How to use the sort lines, reverse & shuffle text

  1. 1Paste your list, one item per line, or open a text file.
  2. 2Pick Sort, Reverse lines, Reverse text or Shuffle, then the sort mode, order and cleanup options.
  3. 3Copy the result, download it, or press Use as input to chain another step.

When to use it

  • A class list by surname

    Paste "Ada Lovelace", "Alan Turing", "Grace Hopper" and pick Last word. You get Hopper, Lovelace, Turing without retyping a single name.

  • Numbered files and versions

    photo-9.jpg and photo-10.jpg, or v1.2 and v1.10, come out in the order you'd number them by hand with Natural.

  • Cleaning a keyword or email list

    Trim, dedupe and sort a list copied from a spreadsheet in one step. If you need to keep the original order instead, remove duplicate lines without sorting.

  • A fair running order

    Shuffle speakers, quiz questions or raffle entries. To draw just one winner, pick a random name instead.

  • Logs, newest first

    Reverse lines flips a log or chat export so the latest entry sits at the top.

Why does 10 sort before 2, and how do I fix it?

Alphabetical sorting compares text one character at a time. In "Chapter 10" and "Chapter 2", the first difference is 1 against 2, and 1 wins. The sort never sees the whole number.

Natural sorting fixes that. It reads each run of digits as a number, so Chapter 2 comes first. Use it for file names, chapter titles and version numbers.

Numeric sorting is for lines that are mostly a value, like prices or test scores. It takes the first number on the line, including a minus sign, decimals and comma thousands separators. One gotcha: in Natural mode 3.10 sorts after 3.2, because 10 is bigger than 2. That's right for versions and wrong for decimals. Numeric treats 3.10 as 3.1, so it goes first. Lines with no number go to the bottom in both directions.

Alphabetical and Natural use Intl.Collator, the browser's implementation of the Unicode Collation Algorithm with your language's rules. É sits next to E, not after Z, and Apple sits right before apple.

How do you shuffle a list fairly?

A list of 10 items has 3,628,800 possible orders. A fair shuffle gives each one the same chance. A popular shortcut in code, sorting with a random comparison, does not. Some orders turn up far more often than others.

This tool uses the Fisher–Yates shuffle, first described in 1938 and adapted for computers by Richard Durstenfeld in 1964. It walks from the last line to the first and swaps each one with a randomly chosen line at or before it. The random numbers come from crypto.getRandomValues in the Web Crypto API. Rejection sampling removes the slight bias you'd get from a plain remainder. Nobody can predict the result, us included.

In what order do the cleanup options run?

Cleanup always happens before the sort, reverse or shuffle:

  • Trim spaces strips spaces and tabs from both ends of each line.
  • Remove empty lines drops lines that are blank or hold only spaces.
  • Remove duplicates keeps the first copy. With Ignore case on, Apple and apple count as one line.
  • Then your chosen operation runs. Lines that compare as equal keep their input order.

Why use Mavros

 MavrosTypical upload sites
Sort, reverse and shuffleOne page, same cleanup optionsOften split across separate pages
2 vs 10, 3.2 vs 3.10Natural and true numeric modesOften plain alphabetical only
Sort by surname, ignore "The"Built inRarely offered
Shuffle randomnessCryptographic, unbiased Fisher–YatesBasic random function, sometimes biased
Emoji when reversingKept intactOften broken into symbols
Limits and uploadsNoneDaily limits, timers or uploads on some sites

Tips

  • Keep Trim spaces on when removing duplicates. Otherwise "date" and "date " with a trailing space count as two different lines.
  • Dates written as YYYY-MM-DD (ISO 8601) sort correctly with plain Alphabetical. Pick Z → A for newest first.
  • Press Use as input to chain steps: remove duplicates, then shuffle what's left.
  • Sorted a list and want to see what moved? Paste both versions into a side-by-side text comparison.
  • Mixed capitals in your list? Convert the case first, then sort.

Questions

How do I sort a list alphabetically?

Paste your list with one item per line. Sort, Alphabetical and A → Z are already selected, so the sorted list appears beside it. Copy it or download it as a .txt file.

Why are capital letters sorted first?

With Ignore case off, a capital letter comes just before the same lowercase letter, so Apple lands right before apple. Turn on Ignore case and the two count as equal, keeping the order you pasted them in.

How do I sort names by last name?

Choose Sort by Last word. Each line is sorted by its final word, such as Lovelace in Ada Lovelace. When two people share a surname, the full line breaks the tie.

Can I remove duplicates while sorting?

Yes. Turn on Remove duplicates and the first copy of each line is kept. The counter shows how many were dropped. Trim spaces and Ignore case catch near duplicates too.

Is the shuffle truly random?

Yes. It uses an unbiased Fisher–Yates shuffle with your browser's cryptographic random generator, so every order is equally likely. The same generator is used for encryption keys.

What is the difference between Reverse lines and Reverse text?

Reverse lines flips the order of the lines and leaves each line alone. Reverse text flips characters, either across the whole text or inside each line, or flips the word order in each line.

Does it handle other languages and emoji?

Yes. Sorting follows your browser's language rules. Length counts an emoji or accented letter as one character, as a Word Counter does, and reversing keeps them whole.

How long can my list be?

There's no fixed limit. Up to 25,000 lines update as you type. Longer lists update when you press Apply or Ctrl+Enter. A 200,000-line natural sort can take several seconds on a slower laptop.

Is my text uploaded anywhere?

No. Sorting, reversing and shuffling all happen in your browser. Nothing you paste or open is sent to a server.