Line Sorter
Sort lines of text alphabetically, reverse alphabetically, by length, numerically, or randomly. Supports case-insensitive sorting and removing blank lines.
Sort method
How to Use Line Sorter
- 1Paste or type text with one item per line.
- 2Choose a sort method: alphabetical, by length, numeric, or random.
- 3Toggle case-insensitive sorting and blank line removal.
- 4Copy the sorted output.
Zenovay
Privacy-first analytics for your website
Understand your visitors without invasive tracking. GDPR compliant, lightweight, and powerful.
Related Tools
Word CounterCount words, characters, sentences, and paragraphs. Estimate reading and speaking time.
Character CounterCount characters with and without spaces. Track limits for Twitter, meta descriptions, and more.
Case ConverterConvert text between UPPERCASE, lowercase, Title Case, camelCase, snake_case, and kebab-case.
Lorem Ipsum GeneratorGenerate placeholder text in paragraphs, sentences, or words. Copy with one click.
Frequently Asked Questions
What is lexicographic (alphabetical) sorting?▾
Lexicographic sort compares strings character by character using Unicode code points. Uppercase letters (A=65) sort before lowercase (a=97) by default. Numbers at the start of strings: "10" comes before "2" lexicographically (because "1" < "2" at position 0). For natural number sorting ("2" before "10"), use the numeric sort option. Case-insensitive mode converts all lines to lowercase for comparison before sorting.
How do I sort a list of numbers correctly?▾
Use numeric sort mode. Alphabetical sort treats all values as strings, so "10" < "2" (because "1" < "2" character-wise). Numeric sort uses parseFloat() to compare numeric values, placing 2 before 10. Lines that cannot be parsed as numbers are sorted separately. For mixed content (numbers and strings), all lines are compared by their parsed numeric value where possible.
How is random sort (shuffle) different from sorting?▾
Random sort uses the Fisher-Yates shuffle algorithm, which produces a uniformly random permutation. It is used to randomize the order of a list — for example, shuffling a list of names for random assignment, randomizing flashcards, or creating random playlists. Each shuffle run produces a different order. Note: the built-in Math.random() is not cryptographically secure — do not use for security-sensitive randomization.
How do I sort lines in a file on the command line?▾
Linux/Mac: "sort file.txt" (alphabetical), "sort -r file.txt" (reverse), "sort -n file.txt" (numeric), "sort -k2 file.txt" (by field 2). "shuf file.txt" shuffles. Windows PowerShell: "Get-Content file.txt | Sort-Object". Python: "sorted(open('f.txt').readlines(), key=str.casefold)". These handle files of any size, while browser tools are limited by available memory.
What is a stable sort?▾
A stable sort preserves the original relative order of elements that compare as equal. JavaScript's Array.prototype.sort() is guaranteed stable since ECMAScript 2019 — all modern browsers implement stable sort. This means lines with identical sort keys (e.g., same length in length-sort mode) appear in their original order relative to each other. The sort results in this tool are stable.