Text Sorter
Sort lines alphabetically, naturally, by number or length — or shuffle them.
Or drop a text file on the box. Nothing leaves your device.
Options
About the Text Sorter
Paste a list and sort it the way you need: alphabetically A → Z or Z → A, in natural order so file2 comes before file10, by the first number in each line, by length, or by raw character code. You can also reverse the current order or shuffle the lines into a random order.
Alphabetical sorting uses your browser's Unicode collation (Intl.Collator), so accented letters land where readers expect them, and you can choose the rules of a specific language — Swedish puts ö after z, German files it with o. Options remove blank lines and duplicates, ignore letter case, and control whether the result ends with a line break.
How to use it
- Paste one item per line, or use Open file (or drop a file on the box) to load a text file from your device.
- Choose Sort by — natural, alphabetical, numeric, length, character code, reverse or shuffle — and the direction.
- Adjust the options if needed: Ignore case, Ignore spaces at line ends, Remove duplicates, Remove blank lines, the Language used for alphabetical order and the Final line break.
- Copy or download the sorted lines. With Shuffle, press Shuffle again for a new random order.
Examples
file10.txt file2.txt file1.txt
file1.txt file2.txt file10.txt
Plain alphabetical order gives file1, file10, file2, because it compares one character at a time.
10 kg sugar 2 kg rice -3 °C 1,000 g flour
-3 °C 2 kg rice 10 kg sugar 1,000 g flour
banana Apple apple Banana
Apple Banana apple banana
With Ignore case off, capital letters A–Z come before small letters a–z.
Common uses
- Alphabetizing names, glossary terms, references or a list of tags.
- Ordering numbered items — chapters, invoice numbers, versions, file names — the way a person would.
- Ranking rows by a number at the start of each line, such as prices, scores or quantities.
- Picking a fair random order for a draw, a quiz or a presentation queue.
Sorting methods
- Natural — alphabetical, but runs of digits compare as numbers:
Chapter 2beforeChapter 10,v1.9beforev1.10. - Alphabetical — dictionary order for the chosen language. With Ignore case on,
appleandApplecount as equal. - Numeric — by the first number in each line, including negatives (
-3), decimals (2.5), exponents (1e3) and thousands separators in Western (1,234,567) or Indian (12,34,567) style. A hyphen joined to a word is not a minus sign, soINV-1001sorts as 1001. Lines without a number go to the end. - Length — by the number of characters (an emoji or an accented letter counts as one). Lines of equal length are sorted A → Z.
- Character code — by Unicode code point, the order used by
sortwithLC_ALL=Cand by Python'ssorted(). Capital letters come before small letters, and accented letters come afterz. - Reverse — flips the current order without sorting.
- Shuffle — a random order from the browser's cryptographic random number generator.
Equal lines keep their order
The sort is stable: lines that compare as equal — for example Apple and apple with Ignore case on, or two lines with the same number in numeric mode — stay in the order they had in your input. That makes results predictable and lets you sort in several passes.
How the shuffle works
Shuffling uses the Fisher–Yates algorithm with random numbers from crypto.getRandomValues. Each random number is drawn with rejection sampling, which avoids the small bias of the common random % n shortcut, so every possible order of your lines is equally likely.
Limitations
- Numeric sort expects a dot as the decimal separator. In
3,5(a decimal comma) only the3is used. - Whole lines are sorted. Words within a line and individual CSV columns are not sorted separately.
- Alphabetical order comes from your browser's collation data, so very old browsers can order rare characters slightly differently.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
Why does file10 come before file2?
That is plain alphabetical order: it compares one character at a time, and 1 comes before 2. Choose Natural to compare the numbers as numbers.
How do I sort from Z to A?
Choose Alphabetical or Natural and select Z → A. Reverse is different: it flips the existing order without sorting anything.
Is the shuffle really random?
Yes. It uses crypto.getRandomValues, the browser's cryptographically secure random generator, with the Fisher–Yates algorithm and rejection sampling, so every order is equally likely. Press Shuffle again for a new order.
Can it remove duplicates while sorting?
Turn on Remove duplicates. It follows the comparison options: with Ignore case on, Apple and apple count as the same line. To keep the last copy or list only repeated lines, use the Duplicate Line Remover.
Does it sort Hindi, Chinese and other languages correctly?
Choose the language under Language to use its dictionary order. Chinese can be sorted by pinyin or by stroke count.
Is my text uploaded?
No. Sorting happens in your browser and nothing you paste or open is sent anywhere.