Sorting lines of text
Sort Lines puts any list in order: keywords, tags, names, URLs, CSS class lists, file names, glossary terms or .htaccess rules you want to review. Paste the list, pick a sort order and copy the result — no spreadsheet needed.
Plain alphabetical sorting puts image-10.jpg before image-2.jpg, because it compares the characters "1" and "2". Natural order compares numbers inside text by their value, so image-2.jpg comes before image-10.jpg, which is what people expect for file names, versions and numbered items. Other modes sort by line length, by the first number in each line (prices, counts, scores), reverse the current order, or shuffle the lines randomly.
Options control the details: case sensitivity, whether leading spaces are ignored, dictionary-style (locale-aware) comparison for accented letters, and removing duplicate or empty lines in the same step.
How to use the Sort Lines
- Paste your list into the input box, one item per line, or click Sample.
- Choose a sort order under Sort by — alphabetical, natural, length, numeric, reverse or shuffle.
- Set the options: case-sensitive, ignore leading whitespace, locale-aware, remove duplicates, remove empty lines.
- Copy or download the sorted lines. In shuffle mode, click Shuffle again for a new random order.
Example
The same file names in alphabetical vs. natural order:
Alphabetical: Natural:
image-1.jpg image-1.jpg
image-10.jpg image-2.jpg
image-2.jpg image-10.jpgSort modes explained
- Alphabetical A → Z / Z → A — dictionary order. Case-insensitive by default, so "apple" and "Apple" sit together.
- Natural order — numbers inside lines are compared as numbers: 1, 2, 10 instead of 1, 10, 2.
- Length — shortest or longest lines first, counted in visible characters. Lines of equal length keep their original order.
- Numeric value — sorts by the first number found in each line, including negatives, decimals and thousands separators such as
1,250. Lines without a number go to the end. - Reverse — flips the current order without sorting, e.g. to show a changelog newest-first.
- Shuffle — random order using your browser's cryptographic random number generator, suitable for picking winners or randomizing quiz questions.
Frequently Asked Questions
What is the difference between locale-aware and plain sorting?
Locale-aware sorting uses your browser's language rules, so "é" sorts next to "e" and "Zoë" next to "Zoe". Plain sorting uses raw Unicode code points, where all accented letters come after "z" — predictable, and what most programming languages do by default.
Does case-sensitive sorting put capital letters first?
Yes. With case sensitivity on, "Apple" comes before "apple", and duplicates are only removed when the case matches exactly. With it off, case is ignored when comparing.
Is the shuffle truly random?
It uses the Fisher–Yates algorithm with crypto.getRandomValues(), so every order is equally likely and results cannot be predicted. Each click on Shuffle again produces a new order.
Can I remove duplicates while sorting?
Yes, tick Remove duplicates. If you need to keep the original order, or want a report of which lines were repeated, use the Duplicate Line Remover.
How do I reverse the characters in each line instead?
Reverse here changes the order of lines. To mirror the text itself, use Reverse Text.