Text Sorter

Sort lines of text alphabetically in ascending or descending order.

How to Use the Text Sorter

  1. Paste your text into the box, with one item per line.
  2. Choose the "Sort Order" and whether to be "Case Sensitive" or "Remove Empty Lines".
  3. Click "Sort Lines" to see the sorted result.

How the Sorting Works

Each line is treated as one item. The tool compares lines character by character from the left, using the code value of each character, which is the same order a computer uses for plain text. In that order, spaces and most punctuation come first, then digits 0 to 9, then capital letters A to Z, then small letters a to z.

With "Case Sensitive" off, every line is compared as if it were in small letters, so capital and small letters sort together. Lines that compare as equal, such as "banana" and "Banana", keep the order they had in your input. For Z to A, the A to Z result is simply reversed.

Worked Example

Input lines, in this order: banana, Cherry, apple, Banana, item 10, item 2, 25, 100.

SettingSorted result
A to Z, case sensitive off100, 25, apple, banana, Banana, Cherry, item 10, item 2
A to Z, case sensitive on100, 25, Banana, Cherry, apple, banana, item 10, item 2
Z to A, case sensitive offitem 2, item 10, Cherry, Banana, banana, apple, 25, 100

Notice that "100" comes before "25" and "item 10" before "item 2". The sorter compares text, not numeric value: the first characters "1" and "2" decide the order before the rest of the number is looked at.

Getting the Order You Expect

  • Pad numbers with leading zeros (002, 010, 025, 100) when you need numeric order, for example for roll numbers or invoice numbers.
  • Remove leading spaces first. A line that starts with a space sorts ahead of every letter, which can look like a mistake. The Text Formatter's "Trim Each Line" fixes this.
  • For names, decide whether to sort by first name or surname before you paste. The tool always starts from the first character of the line.
  • Text in Hindi and other Indian scripts is ordered by character code. This follows the order of the script's Unicode block, which is close to the traditional varnamala order but may not match a dictionary exactly for conjuncts and vowel signs.
  • Sorting does not remove repeats. Use Remove Duplicate Lines before or after sorting to get a clean unique list.

Frequently Asked Questions

Lines are compared alphabetically (using standard string comparison) and arranged in ascending (A-Z) or descending (Z-A) order, based on your selection.

When enabled, uppercase letters sort before lowercase ones (standard ASCII order), so 'Banana' comes before 'apple'. When disabled, sorting ignores case entirely.

By default, blank lines are removed before sorting. Uncheck 'Remove Empty Lines' to keep them in the output.

Lines are sorted as text, so the first character is compared first: "1" comes before "2", whatever follows. To sort numbers by value, give them the same number of digits with leading zeros, such as 025 and 100.

No. Repeated lines are kept and end up next to each other after sorting. Use the Remove Duplicate Lines tool if you want only one copy of each.
No ratings yet — be the first!
Rate this calculator:
Was this tool helpful?