Text Line Sorter
Sort, reverse, or shuffle lines of text alphabetically, numerically, or by length.
About This Tool
The Text Line Sorter organizes lines of text according to seven different modes: alphabetical (AβZ or ZβA), length-based (shortest or longest first), numeric (correctly sorts 1, 2, 10 instead of 1, 10, 2), random shuffle, and reverse order. Optional settings let you trim leading/trailing whitespace, remove empty lines, number the output lines, and toggle case-sensitive alphabetical sorting.
All sorting runs in the browser using JavaScript's built-inlocaleCompare for alphabetical ordering (which handles accented characters and multilingual text correctly) and standard numeric comparison for numeric mode.
How to Use
- Paste your lines of text into the input area (one item per line), or click Sample to load an example.
- Choose a Sort Mode from the dropdown.
- Toggle options as needed: trim whitespace, remove empties, number lines, case-sensitive.
- Click Sort and copy the result.
Use Cases
Developers sort import statements or CSS class lists alphabetically for consistency. Data analysts sort CSV column values for quick inspection. Writers organize a list of names, items, or bullet points by length for formatting purposes. Educators randomize quiz questions or student names for fair group assignments. Technical writers sort glossary terms alphabetically before publishing documentation.
FAQ
- Does alphabetical sort handle accented characters? β Yes. The AβZ mode uses
localeComparewithsensitivity: 'base'by default, which treats accented variants as equivalent to their base letter (case-insensitive). Enable case-sensitive mode for strict byte-order sorting. - How does numeric sort handle mixed lines? β Lines that start with a valid number are sorted by that number. Lines that do not start with a number fall back to alphabetical ordering after the numeric lines.
- Does random shuffle produce truly random results? β The shuffle uses
Math.random(), which is fast but not cryptographically random. It is suitable for everyday shuffling (quiz questions, lists) but not for security applications. - Is there a line count limit? β No. All processing is in-browser and handles tens of thousands of lines without issue.