TL
Tool Lab
πŸ’°Donate
πŸ’°Donate

Text Line Sorter

Sort, reverse, or shuffle lines of text alphabetically, numerically, or by length.

Input Text (one item per line)
Sort Mode
Options

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

  1. Paste your lines of text into the input area (one item per line), or click Sample to load an example.
  2. Choose a Sort Mode from the dropdown.
  3. Toggle options as needed: trim whitespace, remove empties, number lines, case-sensitive.
  4. 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 localeCompare with sensitivity: '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.