FormatterHQ

Sort Text Lines

Sort lines alphabetically, naturally, by length, in reverse or randomly, with optional de-duplication and case sensitivity.

Input TEXT
Output TEXT
Ready.

How to use the Sort Text Lines

  1. Paste your list with one item per line.
  2. Choose the order: A to Z, Z to A, natural, by length, reversed or random.
  3. Set case sensitivity and decide whether duplicates and empty lines should be removed.
  4. Copy the sorted list.

Sort Lines Alphabetically, Naturally or by Length

Paste a list, choose an order and this tool will sort lines in one step. It handles plain alphabetical order as well as the “natural” order people expect for file names and version numbers.

Example: alphabetical vs natural order

Input        A → Z        Natural
file10.txt   apple        apple
file2.txt    Banana       Banana
Banana       cherry       cherry
apple        file1.txt    file1.txt
file1.txt    file10.txt   file2.txt
cherry       file2.txt    file10.txt

Plain alphabetical sorting compares character by character, and “1” comes before “2”, so file10 lands before file2. Natural sorting reads runs of digits as whole numbers, which puts 2 before 10 and v1.9 before v1.10.

Sort orders explained

  • A → Z / Z → A: standard alphabetical order using your browser's language rules.
  • Natural / natural descending: like A → Z, but numbers inside the text are compared by value.
  • By length / longest first: counts characters per line; lines of equal length are ordered alphabetically.
  • Reverse current order: flips the list without sorting it, so the last line becomes the first.
  • Random: an unbiased shuffle (Fisher–Yates), giving a new order each time. Shuffle Lines does only this.

Case sensitivity

With case sensitivity off (the default), sorting is language-aware: “apple”, “Apple” and “Äpfel” are grouped by their base letters, and accents do not push a word to the end. In A → Z order, lines that differ only in case are placed with the capitalized one first.

With case sensitivity on, the A → Z and Z → A orders compare lines by raw Unicode code points. All capital letters come before all lowercase letters, and accented letters come after “z”:

Case-insensitive:  Äpfel, Apple, apple, zebra
Case-sensitive:    Apple, apple, zebra, Äpfel

Code-point order matches what many programming languages do by default, which helps when you need the same order as a script. The natural and by-length orders ignore this setting and always use the language-aware comparison.

Duplicates and empty lines

Empty lines are removed by default so they do not collect at the top of the list. The duplicate filter keeps one copy of each identical line; it always compares exactly, so “Apple” and “apple” both remain. For case-insensitive de-duplication without sorting, use Remove Duplicate Lines.

Sorting numbers

Alphabetical order puts “100” before “25”. Natural order fixes whole numbers, but it does not understand minus signs or decimal fractions. For lists of numeric values, the Number Sorter compares actual values. To sort titles while ignoring “The” or “A”, try Alphabetical Order.

Privacy

Sorting runs in your browser; the list is not uploaded.

Frequently asked questions

What is natural sort order?
Natural sorting compares groups of digits as numbers rather than character by character. That puts “file2” before “file10” and “chapter 9” before “chapter 12”, which matches how people read lists.
Why is “Zebra” sorted before “apple”?
Case-sensitive sorting uses Unicode code-point order, in which every capital letter comes before every lowercase letter. Turn case sensitivity off for dictionary-style ordering.
Can I sort lines by length?
Yes. Choose by length for shortest first, or longest first for the reverse. Lines with the same number of characters are sorted alphabetically.
Does the duplicate filter ignore upper and lower case?
No. It removes only lines that are exactly identical. Use a dedicated duplicate remover with case sensitivity turned off if “Apple” and “apple” should count as the same.
How do I reverse a list without sorting it?
Choose the reverse current order option. The lines are flipped exactly as they are, last line first, with no alphabetical sorting.

Last updated October 3, 2026

Related tools