Sort lines of text
Sort lines A to Z or Z to A, in natural numeric order, by length, reverse them, or shuffle them randomly.
0 / 2,000,000 characters · Updates as you type.
Paste one item per line and choose an order. Alphabetical sorting uses the Unicode collation built into your browser, so accented letters sort next to their base letters (é with e) instead of after z. Natural order compares numbers inside the text by value, so "item 2" comes before "item 10" and "file9.png" before "file10.png", which plain alphabetical order gets wrong.
You can also sort by length (useful for spotting outliers in a keyword list), reverse the current order, or shuffle the lines. Shuffling uses the Fisher-Yates algorithm with your browser's cryptographic random generator (crypto.getRandomValues) and rejection sampling, so every order is equally likely, which is what you want for drawing names or randomising a quiz.
Ties are broken by the exact text, so the same input always sorts the same way.
How to use it
- Paste your lines into the box.
- Choose the order, and decide whether case matters and whether empty lines should be removed.
- Copy or download the sorted list. Press the Sort button again to reshuffle.
Frequently asked questions
What is natural sort order?
An order that treats runs of digits as numbers: 1, 2, 10 rather than 1, 10, 2. It is how most file managers sort file names.
How random is the shuffle?
It uses crypto.getRandomValues with rejection sampling to avoid modulo bias, and the Fisher-Yates algorithm, which gives every permutation the same probability.
How are Arabic and other scripts sorted?
By the Unicode Collation Algorithm defaults in your browser. Arabic lines sort in Arabic alphabetical order, and mixed-script lists group each script together.
Can I sort by a column in CSV data?
Not directly; lines are compared from their first character. For column sorting, open the CSV in a spreadsheet.
Related tools
- Remove duplicate linesDelete repeated lines from a list, keeping the first or last occurrence, with case-sensitivity and trimming options.
- Remove extra spaces and blank linesTrim lines, collapse repeated spaces, remove or collapse blank lines, convert tabs and spaces, and strip invisible characters.
- Compare text (diff checker)Compare two texts line by line or word by word and see additions and deletions side by side or inline.
- Random number generatorUniform random integers in any range from crypto.getRandomValues, one or many, with or without repeats.
- Case converterConvert text to UPPER, lower, Title Case, Sentence case, camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE.