Text Line Sorter
To sort text lines online: paste your list (one item per line) into the input box, select a sort mode (A→Z alphabetical, Z→A, shortest/longest first, numeric ascending/descending, reverse, or random), and the sorted output appears instantly. Enable "Remove duplicate lines" to deduplicate with optional case-insensitive matching. Enable "Trim whitespace" to normalize spacing before sorting.
Sort text lines alphabetically, numerically, by length, or randomly. Remove duplicate lines, trim whitespace, and remove empty lines. Supports ascending and descending order. Instant sorting — paste your list and get sorted output in one click.
Input Lines
Sorted Output
Sort Options
Sort Mode Reference
| Mode | Description | Example |
|---|---|---|
| A → Z | Alphabetical ascending (default locale-aware) | "Apple" before "Banana" |
| Z → A | Alphabetical descending | "Zebra" before "Apple" |
| Shortest first | Sort by line length, shortest first | "Hi" before "Hello World" |
| Longest first | Sort by line length, longest first | "Hello World" before "Hi" |
| Numeric ascending | Sort numbers smallest to largest | 1, 7, 42, 100 |
| Numeric descending | Sort numbers largest to smallest | 100, 42, 7, 1 |
| Reverse order | Flip the current order of lines | Last line becomes first |
| Random / shuffle | Randomize line order (Fisher-Yates) | Random each time |
How to Use
- 1
Paste your list
Type or paste your text into the input box — one item per line. Use the sample buttons to load a fruit list, numbers, or CSS class names for a quick demo.
- 2
Choose a sort mode
Click your preferred sort method: A→Z alphabetical, Z→A, shortest first, longest first, numeric ascending, numeric descending, reverse order, or random/shuffle.
- 3
Set options
Enable "Remove duplicate lines" to deduplicate. Toggle "Case-insensitive dedup" so "Apple" and "apple" count as the same. Enable "Trim whitespace" and "Remove empty lines" for cleaner output.
- 4
Copy the result
The sorted output appears instantly in the right panel. Click Copy to copy all sorted lines to your clipboard. The stats bar shows the final line count and how many duplicates were removed.
Frequently Asked Questions
- How do I sort text lines alphabetically online?
- Paste your text into the input box (one item per line), select "A → Z (alphabetical)" sort mode, and the sorted output appears instantly. The sorter uses locale-aware comparison so accented characters (é, ü, ñ) sort correctly relative to their base letters. For case-insensitive alphabetical sorting, enable the "Case-insensitive dedup" option — sorting is always case-insensitive by default.
- How do I remove duplicate lines from a text list?
- Check the "Remove duplicate lines" checkbox before or after pasting your text. Duplicates are identified after optional trimming is applied. With "Case-insensitive dedup" enabled, "Apple" and "apple" are treated as the same line. The stats bar shows how many duplicates were removed. The deduplication preserves the first occurrence of each line and removes subsequent occurrences.
- Can I sort numbers numerically (not alphabetically)?
- Yes — select "Numeric ascending" or "Numeric descending" sort mode. This sorts lines by their numeric value so 1, 7, 42, 100 sorts correctly (instead of alphabetical order: 1, 100, 42, 7). Lines that cannot be parsed as numbers fall back to string comparison. Useful for sorting lists of IDs, prices, scores, or any numeric data.
- What does "Sort by length" do?
- "Shortest first" sorts lines by character count, shortest to longest. "Longest first" does the reverse. When two lines have the same length, they are sub-sorted alphabetically. Length sorting is useful for organizing CSS class names, code snippets, or lists where brevity is meaningful — for example, finding the shortest or longest item in a set.
- What is the "Reverse order" sort mode?
- "Reverse order" flips the current sequence of lines — the last line becomes first and the first line becomes last. It does not sort alphabetically or numerically; it simply inverts the order of lines as pasted. This is useful for reversing a numbered list, flipping a timeline, or undoing a previous sort.
- How does the random / shuffle mode work?
- The "Random / shuffle" mode randomizes line order using the Fisher-Yates algorithm, which produces a uniformly random permutation. Each click of the sort button (or any option change) re-shuffles the lines. Use it to randomize a list for random assignment, lottery draws, or presentation order.