Text Sorter
Sort lines alphabetically, numerically, by length, or randomly — with case-sensitive and reverse order options.
Last updated: March 25, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is Text Sorter?
Sorting lines of text is a foundational data processing operation needed across many daily workflows. Developers sort lists of dependency names before committing package.json changes. Content writers sort glossary entries alphabetically. Data analysts sort comma-separated values by numeric score. System administrators sort log lines by timestamp. Database engineers sort database column lists before generating schema documentation.
This tool provides all common sort modes in one place: alphabetical (A-Z and Z-A), numeric (sorts digit strings as numbers, not as text — "10" sorts correctly after "9"), by line length (shortest-first or longest-first), and random shuffle (useful for randomizing a list of items for testing or lottery purposes). All operations are applied instantly using JavaScript's optimized sort algorithms.
How to Use Text Sorter
Paste your list of lines (one item per line) into the input area
Select your sort mode: Alphabetical, Numeric, By Length, or Random Shuffle
Choose Ascending (A-Z / small-to-large) or Descending (Z-A / large-to-small)
Toggle "Case Insensitive" if you want "banana" and "Banana" to sort as equal
Click "Copy Result" to copy the sorted output to your clipboard
Common Use Cases
- Sorting a list of npm dependencies alphabetically before import in a package.json or import block
- Alphabetizing a list of country names, country codes, or language options for a configuration file
- Sorting a reading list, word list, or tag list alphabetically for a documentation site
- Ranking search result URLs or domain names by their length to analyze character count patterns
- Shuffling a list of team members randomly for turn-order assignment
- Sorting a CSV column of scores or timestamps numerically for analysis
- Sorting a list of CSS class names, HTML attributes, or JSON keys before code review
- Reversing a list of git commits (oldest-first to newest-first) for documentation
Example Input and Output
Sorting a mixed list of programming language names alphabetically (case-insensitive):
Python
javascript
TypeScript
rust
Go
ruby
JAVA
kotlin
swiftGo
JAVA
javascript
kotlin
Python
ruby
rust
swift
TypeScriptClient-Side Processing
All sorting operations happen locally in your browser. The text you paste — including configuration values, email lists, or sensitive data — is never transmitted to our servers.
Sorting for Code Style
Alphabetically sorted imports and CSS properties are a common code style rule (enforced by ESLint "sort-imports" or Stylelint "declaration-property-sort-order" rules). Paste your unsorted import block or CSS declarations here, sort alphabetically, and paste back — much faster than manually reordering.
Command-Line Alternative
The Unix sort command is extremely powerful for file-based sorting: sort -u (sort + deduplicate), sort -n (numeric), sort -r (reverse), sort -k2 (by second column in CSV). For large files (millions of lines), use sort from the command line rather than a browser tool — it uses optimized external merge sort for files larger than available RAM.
Frequently Asked Questions
What is the difference between alphabetical and numeric sorting?
Does sorting preserve blank lines?
How does "By Length" sorting work?
Is the "Random Shuffle" truly random?
Can I sort with multiple criteria (primary + secondary)?
How does locale-aware alphabetical sorting work?
How This Tool Works
The input is split into a line array using \n as the delimiter. Depending on the selected mode: Alphabetical uses Array.sort() with localCompare() or direct code point comparison; Numeric uses sort((a, b) => parseFloat(a) - parseFloat(b)); By Length uses sort((a, b) => a.length - b.length); Random Shuffle implements the Fisher-Yates algorithm with Math.random(). Ascending/Descending is applied by either using the natural sort comparison or negating it. Case insensitivity lowercases both operands in the comparator function only. The sorted array is then joined with \n and displayed.
Technical Stack