Last updated
Text Sorter Examples
The Text Sorter arranges lines of text in alphabetical, numerical, natural, or custom sort orders. Below are practical examples covering all sort modes with real-world use cases.
Alphabetical Sort (A-Z)
// Input
cherry
apple
date
banana
elderberry
// Alphabetical sort (A-Z)
apple
banana
cherry
date
elderberry
Reverse Alphabetical Sort (Z-A)
// Input
cherry
apple
date
banana
// Reverse sort (Z-A)
date
cherry
banana
apple
Case-Sensitive vs Case-Insensitive Sort
// Input
Banana
apple
Cherry
date
// Case-sensitive sort (uppercase before lowercase)
Banana
Cherry
apple
date
// Case-insensitive sort (mixed together)
apple
Banana
Cherry
date
Natural Sort (Numbers in Text)
// Input (filenames with numbers)
file10.txt
file2.txt
file1.txt
file20.txt
file3.txt
// Lexicographic sort (wrong for filenames)
file1.txt
file10.txt
file2.txt
file20.txt
file3.txt
// Natural sort (correct numeric ordering)
file1.txt
file2.txt
file3.txt
file10.txt
file20.txt
Natural Sort for Version Numbers
// Input
v1.10.0
v1.2.0
v1.9.0
v2.0.0
v1.1.0
// Lexicographic sort (wrong)
v1.1.0
v1.10.0
v1.2.0
v1.9.0
v2.0.0
// Natural sort (correct)
v1.1.0
v1.2.0
v1.9.0
v1.10.0
v2.0.0
Numerical Sort
// Input (prices)
29.99
5.00
149.99
12.50
99.00
// Numerical sort (ascending)
5.00
12.50
29.99
99.00
149.99
// Numerical sort (descending)
149.99
99.00
29.99
12.50
5.00
Sort and Deduplicate
// Input (list with duplicates)
cherry
apple
banana
apple
cherry
date
banana
// Sort + remove duplicates
apple
banana
cherry
date
Sort by Column (CSV Data)
// Input (tab-separated, sort by column 2 = score)
Alice 85 Engineering
Bob 92 Marketing
Carol 78 Engineering
Dave 95 Marketing
Eve 88 Engineering
// Sorted by score (column 2, descending)
Dave 95 Marketing
Bob 92 Marketing
Eve 88 Engineering
Alice 85 Engineering
Carol 78 Engineering
Sort Dates
// Input (ISO 8601 dates sort correctly alphabetically)
2024-03-15
2024-01-01
2024-12-31
2024-06-20
2024-02-14
// Alphabetical sort (works correctly for ISO dates)
2024-01-01
2024-02-14
2024-03-15
2024-06-20
2024-12-31
// Note: Use ISO 8601 (YYYY-MM-DD) format for correct date sorting
// US format (MM/DD/YYYY) does NOT sort correctly alphabetically
Random Shuffle
// Input (quiz questions)
What is 2 + 2?
What is the capital of France?
Who wrote Hamlet?
What year did WWII end?
// Random shuffle output (different each time)
Who wrote Hamlet?
What is 2 + 2?
What year did WWII end?
What is the capital of France?
Locale-Aware Sort (Non-English)
// French locale sort (accented characters in correct position)
Input:
école
étude
eau
été
enfant
// Standard Unicode sort (incorrect for French)
eau
enfant
école
étude
été
// French locale sort (correct)
eau
école
enfant
étude
été
Sort URL List
// Input
https://example.com/products
https://example.com/about
https://example.com/contact
https://example.com/blog
https://example.com/api/users
// Alphabetical sort
https://example.com/about
https://example.com/api/users
https://example.com/blog
https://example.com/contact
https://example.com/products
JavaScript Sort Examples
const lines = text.split('\n');
// Alphabetical (case-insensitive)
lines.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
// Reverse alphabetical
lines.sort((a, b) => b.toLowerCase().localeCompare(a.toLowerCase()));
// Numerical
lines.sort((a, b) => parseFloat(a) - parseFloat(b));
// Natural sort
lines.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
// Random shuffle
lines.sort(() => Math.random() - 0.5);
Common Use Cases
- Sort keyword lists alphabetically for SEO or documentation
- Sort filenames with natural sort for correct numeric ordering
- Sort version numbers to find the latest release
- Sort and deduplicate email or subscriber lists
- Sort CSV data by a specific column
- Sort ISO dates chronologically
- Shuffle quiz questions or test cases randomly
- Verify that data is already in the expected sort order
Paste your text into the Text Sorter, choose your sort mode, and get a perfectly ordered list in seconds.