Sort Lines
Sort lines alphabetically, by length, numerically, in reverse, or shuffle randomly.
How to Use
- Paste your list of lines into the input box.
- Select a sort mode: A–Z, Z–A, shortest first, longest first, numeric, or shuffle.
- Toggle "Case insensitive" to treat uppercase and lowercase letters as equal.
- Enable "Remove duplicates" to deduplicate while sorting.
When to Use This
- Version strings and ID exports fall into sensible order under Numeric mode, which places 10 after 9 rather than before it.
- Reviewing a long dependency file or .gitignore is faster alphabetically, and the duplicate toggle clears repeated entries in the same pass.
- Drawing a random winner or assigning a fair running order is what Shuffle covers, reordering the entire list in one move.
- Longest first brings overlong page titles or product names to the top when you are auditing a list against a length budget.
Frequently Asked Questions
About This Tool
Alphabetical order in software usually means code point order, and that is not the order a dictionary or a phone book uses. Comparing raw character values puts every uppercase letter ahead of every lowercase one, places digits before letters, and sends accented characters such as e-acute past z. A locale-aware collation fixes that, at the cost of giving different results in different languages.
This tool compares lines with JavaScript's less-than and greater-than operators, so you get code unit order rather than locale collation, and Case insensitive lowercases both sides before the comparison. Shortest and longest first compare line length and fall back to the same ordering for ties. Numeric reads each line with parseFloat, sorts the numbers ascending and pushes lines that do not parse to the end. Shuffle is a Fisher-Yates pass. Remove duplicates runs after the sort and always trims before comparing.
Notes & Limits
- Comparison is on UTF-16 code units, not locale collation, so Zebra sorts before apple in case-sensitive mode and accented letters land after z.
- Numeric mode uses parseFloat, so a line beginning 12 apples sorts as 12, and any line not starting with a number is pushed to the end.
- Shuffle draws from Math.random(), which is adequate for ordering a list but not for a draw that has to be auditable or unpredictable to an attacker.
- Remove duplicates here always trims the comparison key and runs after sorting; use Remove Duplicate Lines when the original order must be kept.