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.
All sorting runs in the browser using JavaScript's built-in localeCompare 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. Data analysts sort CSV column values for quick inspection. Writers organize lists by length for formatting. Educators randomize quiz questions or student names for fair group assignments.
FAQ
- Does alphabetical sort handle accented characters? — Yes. The A→Z mode uses localeCompare with sensitivity: 'base' by default, which treats accented variants as equivalent to their base letter.
- 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.
- 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 but not for security applications.