Overview
Introduction
Alphabetizing a pasted list, names, tags, file paths, is quick with a dedicated sort instead of manually reordering lines by eye.
It runs entirely client-side, so nothing you paste is ever uploaded to a server.
What Is Text Sorter?
A line sorter that alphabetizes newline-separated text using locale-aware string comparison, with an option to reverse the order.
It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.
How Text Sorter Works
The input is split into lines, sorted with localeCompare() for human-friendly ordering, and optionally reversed for descending order.
The transformation happens synchronously in JavaScript the moment you type, with no network round trip involved.
When To Use Text Sorter
Use it to alphabetize a pasted list of names, tags, or file paths.
It's a fast way to get the answer without opening a code editor, a REPL, or writing a one-off script just to check.
Often used alongside Text Splitter and Text Joiner.
Features
Advantages
- Locale-aware comparison generally matches human expectations better than raw character-code sorting.
- One-click toggle between ascending and descending order.
- Uses locale-aware comparison, so accented letters sort alongside their base letters instead of being pushed to the end as raw code point order would place them.
Limitations
- Doesn't deduplicate; repeated lines remain repeated, just adjacent after sorting.
- Sorts every line including blank ones, which gather together at one end of the result rather than being dropped.
Examples
Best Practices & Notes
Best Practices
- Remove duplicate or blank lines first if you need a clean, deduplicated sorted list.
- Zero-pad numeric values before sorting so they come out in the order a reader expects rather than in lexical order.
- Remove trailing whitespace first, since a line ending in a space sorts differently from an otherwise identical one.
Developer Notes
Sorting uses `(a, b) => a.localeCompare(b)` rather than the default comparator (which sorts by UTF-16 code unit and can produce surprising results for accented characters or mixed case), then optionally reverses the array for descending order.
Text Sorter Use Cases
- Alphabetizing a pasted list of names or tags
- Sorting file paths or identifiers for review
- Preparing a sorted list for a changelog or index
Common Mistakes
- Expecting duplicates to be removed automatically.
- Sorting a list that begins with a header row, which is shuffled into the body along with everything else.
Tips
- Pair with Remove All Empty Lines first if your pasted list has stray blank lines.
- Sorting brings identical lines together, which makes duplicates immediately visible even though nothing is actually removed.