Text Tools

Text Sorter

Sort lines of text alphabetically, by length, numerically, or in random order. Trim whitespace and remove duplicates with a click.

Run tool

The Text Sorter tool organizes lines of text in various ways. Paste your list into the text area, choose a sorting method, and click Run. You can sort alphabetically (A to Z or Z to A), by line length (shortest or longest first), numerically (lowest or highest number first), randomly, or in reverse order. By default, whitespace at the start and end of each line is trimmed. You can disable trimming to preserve spacing. Duplicate removal is off by default; when enabled, only the first occurrence of each line is kept. For alphabetical sorting, comparisons are case-insensitive by default, but you can enable case-sensitive sorting. Numeric sorting treats non-numeric lines as zero. Random mode shuffles lines unpredictably. Reverse mode flips the order of the processed lines. If the input is empty, the output will be empty.

Instructions

  1. Paste or type your text into the Text area. Each line will be sorted separately.
  2. Select a sorting method from the dropdown: A to Z, Z to A, Shortest first, Longest first, Lowest number first, Highest number first, Random order, or Reverse line order.
  3. Optional: Check Case Sensitive to make alphabetical sorting case-sensitive.
  4. Optional: Check Remove Duplicates to keep only the first occurrence of each line.
  5. Optional: Uncheck Trim Whitespace if you want to keep leading or trailing spaces on each line.
  6. Click Run to sort your text. The sorted result appears in the output panel.

Examples

  • Sort a list of names alphabetically: Input: "Charlie", "Alice", "Bob" -> Output: "Alice", "Bob", "Charlie" (A to Z mode).
  • Sort numbers numerically: Input: "10", "2", "33", "1" -> Output: "1", "2", "10", "33" (Lowest number first mode).
  • Remove duplicate lines: Input: "apple", "banana", "apple", "cherry" -> Output: "apple", "banana", "cherry" (with Remove Duplicates enabled).

FAQ

What happens if I leave the text input empty?

The output will be empty.

How does numeric sorting handle lines that are not numbers?

Lines that cannot be converted to a number are treated as having a value of zero for sorting purposes. They appear before positive numbers and after negative numbers.

Can I sort case-sensitively?

Yes. Check the Case Sensitive option. When enabled, uppercase letters are sorted before lowercase letters (e.g., 'Apple' before 'apple').

Does random mode produce the same order every time?

No. Random mode shuffles the lines, so the order is nondeterministic and will vary each time you run the tool.

What does the Trim Whitespace option do?

By default, leading and trailing spaces are removed from each line before sorting. Uncheck this option if you need to preserve the original spacing.

Embed this tool

Add this working SmartPlusLab tool to your website with the code below.