How Does the Online List Alphabetizer Work?
The alphabetizer splits text on newline boundaries (\n) and orders lines using Unicode-aware natural collation so multi-digit numbers sort by value (Item 2 before Item 10) rather than ASCII code point.
Text Cleaner uses natural locale-aware sorting rules (localeCompare with numeric collation). Numbers inside items (such as Item 2 and Item 10) are ordered logically rather than strictly as raw characters.
What Algorithm & Collation Rule Does Sorting Use?
Line sorting executes lines.sort((a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" })) for A–Z order, and reverses the comparator for Z–A order.
- Line Tokenization Rule: Split input on
\n(U+000A), sort array in memory, and rejoin with\n. - Case-Insensitive Base Sensitivity:
appleandApplecompare by base character rather than separating uppercase and lowercase ASCII blocks. - Worked Before / After Example: Input
Zebra\nApple\nMango\nBanana\nOrange(5 lines, 5 words, 31 characters) → OutputApple\nBanana\nMango\nOrange\nZebra(5 lines, 5 words, 31 characters, 4 line positions reordered).
| Sorting Mode / Algorithm Rule | Input Example (Before) | Output Result (After) | Lines Reordered (count) |
|---|---|---|---|
Sort A–Z (localeCompare ascending) |
Zebra\nApple\nMango (3 lines, 17 chars) |
Apple\nMango\nZebra (3 lines, 17 chars) |
3 lines reordered (0 chars lost) |
Sort Z–A (localeCompare descending) |
Apple\nMango\nZebra (3 lines, 17 chars) |
Zebra\nMango\nApple (3 lines, 17 chars) |
2 lines swapped (0 chars lost) |
Natural Numeric Collation (numeric: true) |
Chapter 10\nChapter 2\nChapter 1 (3 lines, 30 chars) |
Chapter 1\nChapter 2\nChapter 10 (3 lines, 30 chars) |
3 lines ordered numerically |
| Deduplicate + Sort A–Z Pipeline | Banana\nApple\nBanana (3 lines, 19 chars) |
Apple\nBanana (2 lines, 12 chars) |
1 duplicate line removed (-7 chars) |
How Can You Combine Sorting with Deduplication?
Click Dedupe first to strip repeated lines in O(n) time, then click Sort A–Z to produce a unique, alphabetically ordered list.
Need a clean, unique sorted list? Click Dedupe to eliminate repeat entries, then click Sort A–Z for a clean alphabetized result.