Text tools

Sort Lines

Sort Lines of Text

Sort lines alphabetically, naturally, by number or by length; reverse or shuffle them, and remove duplicates.

About this tool

About Sort Lines

Paste a list, one item per line, and get it back in the order you need. Alphabetical sorting uses your browser's language-aware collation, so accented names such as Émile and Zoë land where a reader expects rather than after Z. Natural order puts file2 before file10 and chapter 9 before chapter 12. Sort by the first number in each line (negative numbers, decimals and thousands separators are understood, and lines without a number go to the end), by character length or by word count, in ascending or descending order. Reverse flips a list without sorting it, Shuffle reorders it with your device's secure random generator, and Keep order lets you just trim and de-duplicate. Library-style sorting can ignore a leading The, A or An. Empty lines are removed by default, duplicates when you tick Remove duplicates, and the status line tells you how many were dropped. With your own AI key, Order by meaning can arrange lines by priority, date words or topic while keeping every line exactly as written.

Built and maintained by Abhi JainUpdated

How to Sort Lines

  1. 1

    Paste the list

    Paste one item per line into the Lines box, or click Sample.

  2. 2

    Pick the order

    Choose A–Z, Natural, By number, By length, By word count, Reverse order or Shuffle, then the Direction.

  3. 3

    Tidy and copy

    Tick Remove duplicates, Remove empty lines or Ignore The / A / An as needed, then Copy or Download the sorted list.

Sort Lines: questions and answers

What is natural sort order?

Natural sorting compares the numbers inside text by value instead of digit by digit. A plain sort gives file1, file10, file2; a natural sort gives file1, file2, file10, which is how people expect file names, versions and chapters to be ordered.

Is the sort case sensitive?

Not by default: apple and Apple sort together. Tick Case sensitive to keep capitalised lines before lower-case ones and to treat them as different when removing duplicates.

How random is the shuffle?

It uses the Fisher–Yates shuffle driven by crypto.getRandomValues, so every order is equally likely. Click Shuffle again for a new order. For picking winners, the Random Picker shows the draw.

Can AI sort lines by meaning, like priority or date?

With your own AI key connected, Order by meaning sends the lines to your provider with your instruction (for example "most urgent first"). The reply is checked so every original line appears exactly once and nothing is invented. Without a key, every other sort works offline.

How do I sort a CSV by a column?

This tool sorts whole lines. To sort a CSV by a specific column, open it in the CSV Viewer and sort there, so quoted commas and headers are handled correctly.