Sort Lines
Sort text lines alphabetically, numerically, by length, or in random order. Supports case-insensitive and reverse sorting.
Sort Options
Frequently Asked Questions
parseFloat() on each line to extract the number and sorts by that value. Lines that don't contain a leading number are treated as 0. This correctly sorts 2, 10, 20 (unlike alphabetical, which would give 10, 2, 20).Array.prototype.sort() is guaranteed to be stable in all current browsers (V8, SpiderMonkey, JavaScriptCore). Lines with equal sort keys retain their original relative order.Math.random() for each swap. While sufficient for most use cases, it is not cryptographically secure — don't use it for security-critical applications. Use the Random String Generator for cryptographic randomness.localeCompare() method can sort text according to a specific locale's rules. This tool uses a simple Unicode comparison, which works well for English but may not match expectations for sorting accented or non-Latin characters.
About This Line Sorter
This free line sorter sorts the lines of any text alphabetically (A–Z or Z–A), numerically, or by line length. Options include case-insensitive sorting and removing blank lines before sorting — all processing happens in your browser.
When to use this tool
- Alphabetising a list of names, keywords, or file paths
- Sorting import statements, CSS properties, or config keys
- Deduplicating and sorting a word list in one step
- Organising log lines or data exports by a leading value
Standards & References
How It Works
Paste Your List
Paste any newline-separated list into the input area. Each line is treated as a sortable item.
Choose Sort Method
Select from alphabetical, reverse alphabetical, numerical, by line length, or shuffle. Set case sensitivity and trimming options.
Copy the Result
Click Sort to apply the chosen method. The sorted output appears instantly and can be copied to the clipboard.
Common Use Cases
Alphabetize Lists
Sort bibliographies, reference lists, glossary entries, or ingredient lists alphabetically for consistent, professional formatting.
Sort Numeric Data
Sort version numbers, IDs, prices, or quantities from exported reports numerically — without needing a spreadsheet.
CSS Property Ordering
Alphabetically sort CSS properties within a selector to enforce consistent style ordering as required by some team style guides.
Randomize Survey Options
Shuffle answer choices for surveys or quizzes to reduce order bias before pasting into your form builder.
De-duplicate & Sort Together
Enable "Remove blank lines" to clean a list while sorting, combining two operations in a single run.
Sort by Line Length
Sort lines by character length to find the shortest or longest entries in a dataset — useful for truncating labels or finding outliers.
Related Text Tools
Related Articles
View all articles
Alphabetical Sort Order Isn't Universal: Locale Collation, Swedish Å, and Why Your Database Might Be Sorting Wrong
Alphabetical sort order isn't the same in every language — Swedish Å, Ä, Ö go at the end of the alphabet; German has two competing sort conventions for umlauts; Spanish ñ sits between n and o. Most sort tools and database defaults use Unicode code-point order, which is correct for English and wrong for nearly every other language. Here's what locale-sensitive collation actually is, how to configure it in SQL, JavaScript, and Python, and the case/accent-sensitivity dimensions on top of letter ordering.
Natural Sort vs Lexicographic: Why "file10 Before file2" Happens Differently in Every Language, Database, and File Manager
"file10" sorting before "file2" isn't a bug specific to one tool — it's the default lexicographic behavior across most programming languages, while file managers typically default to natural sort, creating a common mismatch. Here's how Python, JavaScript, SQL ORDER BY, and spreadsheets each handle this differently, and why version-number sorting (SemVer) is a related but distinct problem with its own rules.
Sort Orders Explained: Why "file10" Sorts Before "file2" and When It Matters
"file10" sorts before "file2" alphabetically — which is correct for strings but wrong for filenames. Here's natural sort vs lexicographic sort, locale-aware collation for multilingual names, multi-column SQL ORDER BY, and why stable vs unstable sort algorithms matter in practice.
Sorting Algorithms Explained: Why the Choice Matters at Scale
Bubble sort handles 1,000 items fine but takes hours on 1 million. Quicksort handles both in milliseconds. Here's how common sorting algorithms actually work, why O(n log n) is the comparison sort lower bound, and what TimSort is doing inside Python and Java.
Sort Lines — Sort Any List Alphabetically, Numerically, or by Length
Learn how to sort any text list alphabetically, numerically, by length, or randomly, why numerical sort differs from alphabetical for numbers, and how to use a free sort lines tool for any list.