Sort Text Lines

Sort lines alphabetically, by length, or reverse the order

What is it and how does it work?

Sorting a list of text items is a fundamental data-manipulation task that comes up constantly: alphabetising a list of names, ordering items by number, sorting CSV rows, or arranging configuration entries. While a spreadsheet can do this, pasting text into this tool and clicking Sort is often faster than opening a new file, selecting a column, and using a menu — especially for quick one-off sorts that don't need to be saved.

This tool sorts lines of text alphabetically (A–Z or Z–A), numerically (ascending or descending), by string length, or in reverse order. Options include case-insensitive sorting (so "Banana" and "apple" sort together rather than capital letters first), trimming whitespace before comparing, and removing duplicates after sorting. The output preserves the line structure of the original input.

Common use cases

Frequently asked questions

What is the difference between alphabetical and lexicographic sort?

They are largely the same thing: sorting character by character based on Unicode code point order. The main practical difference is case: uppercase letters (A=65) have lower code points than lowercase (a=97), so "Z" sorts before "a" in pure lexicographic order. Case-insensitive sorting normalises this.

Why does "10" sort before "9" in alphabetical mode?

Alphabetical sorting compares character by character: "1" < "9", so "10" < "9". To sort numbers correctly by their numeric value, use the numeric sort mode, which parses values as numbers before comparing.

Can I sort by a specific column in a CSV?

This tool sorts full lines. For column-aware CSV sorting, use a spreadsheet or a command-line tool like sort -t, -k2. Paste just the column to sort, then re-join it with the rest of the CSV afterwards if needed.

Does sorting work for non-Latin scripts?

Yes. Unicode-aware sorting places characters according to their code point, which roughly follows the order of international alphabets. For language-specific sort collation (e.g., ä after z in Swedish, before b in German), a locale-aware sort using the Intl.Collator API is needed.

Text

Uppercase / Lowercase · Word Counter · Character Counter · Lorem Ipsum Generator · Remove Extra Spaces · Remove Duplicate Lines