Sort Lines

How to use

Sorts the lines of any text alphabetically, numerically, by length, or in reverse order. Useful for tidying up lists, CSV columns pasted as text, or code. Paste your lines, pick a sort mode, and copy the result.

Text UtilitiesLocal only
When to use this
  • Alphabetizing a glossary, reference list, or set of names before publishing
  • Ordering log lines or config entries by length to spot outliers quickly
  • Reversing an exported list that came out newest-first when you need oldest-first
  • Sorting a list of numeric IDs or scores for a quick visual scan

Why sorted output sometimes looks unsorted

The most common surprise is that "10" sorts before "9". Plain sorting compares text character by character, and the character "1" precedes "9", so every string beginning with 1 comes before every string beginning with 9 regardless of numeric value. Natural sorting, which detects digit runs and compares them as numbers, is what produces the order people expect for version strings, filenames and anything with an embedded index. Neither is wrong; they answer different questions, and mixing them up is why file listings sometimes look scrambled.

Case is the second surprise. In a plain byte or code-unit comparison, all uppercase letters sort before all lowercase ones, so "Zebra" comes before "apple". Case-insensitive sorting fixes the appearance, but it also means two entries differing only in case compare as equal, and which one ends up first then depends on whether the sort is stable. A stable sort preserves the original relative order of equal elements, which is what makes it safe to sort by one field and then another to get a compound ordering.

Locale is the third, and it matters more than its obscurity suggests. Accented characters, the Turkish dotless i, and the treatment of digraphs all vary by language, and a "correct" alphabetical order differs between them. Before sorting a list of names or terms that will be read by people, decide which locale's rules apply. And whatever the settings, trim trailing whitespace first: an invisible trailing space changes a comparison, which is the usual explanation for two apparently identical lines refusing to group together.

Free and private. Everything runs on your own device, with no account and no uploads.

Sorting a reference list, ranking log lines by length or flipping an export upside down is slow and error-prone by hand. This tool sorts pasted lines alphabetically (A-Z or Z-A), numerically, by line length, or simply reverses their order, giving developers and writers a quick way to reorganize lists without opening a spreadsheet.

Non-numeric lines are generally treated as having a low or undefined value and pushed to one end; use numeric sort only on lists that are mostly numbers for predictable results.

Sorting uses standard string comparison, so uppercase and lowercase letters can sort differently depending on your browser locale settings.

Yes, the by-length option orders lines from shortest to longest, and you can reverse the result if you need the opposite order.

No, sorting only reorders lines; use the Remove Duplicate Lines tool separately if you also need to deduplicate.

No, sorting happens locally in your browser and nothing is saved or uploaded.

How it works
  1. 1

    Paste your lines

    Enter text with one item per line.

  2. 2

    Select a sort mode

    Choose alphabetical, numeric, by length, or reverse order.

  3. 3

    Apply the sort

    The reordered lines appear in the output area.

  4. 4

    Copy the result

    Copy the sorted list to paste elsewhere.

Pro tips
  • ·Use numeric sort only when the list is mostly numbers, mixed text and numbers can sort unpredictably.
  • ·Check your locale-sensitive expectations for alphabetical sort, since case can affect ordering depending on the browser.
  • ·Run Remove Duplicate Lines first if you need both a clean and sorted list, sorting alone will not drop repeats.