FC

^v️ Line Sorter

Sort, reverse, shuffle or deduplicate lines - all in your browser

6 lines - 5 unique - 0 empty
apple
apple
banana
cherry
date
fig

How to Use the Line Sorter

The Line Sorter instantly organises multi-line text in any order you need - alphabetically, by length, reversed, shuffled, or deduplicated. Perfect for developers sorting lists of names, file paths, CSS classes, JSON keys, or any newline-separated data. Everything runs in your browser - nothing is sent to any server.

Step-by-Step Guide

  1. 1Paste your list into the left panel - one item per line. You can paste from Excel, a CSV column, code, or any text source.
  2. 2Select a sort mode: A->Z for alphabetical, Z->A for reverse alpha, Shortest/Longest for length-based, Reverse to flip order, Shuffle to randomise, or Unique to remove duplicates.
  3. 3Toggle Case Sensitive if you need capital letters to sort before lowercase (default is case-insensitive).
  4. 4The sorted output appears instantly on the right. Click Copy to copy the entire sorted list to your clipboard.
  5. 5Paste the result back into your code, spreadsheet, or document.

Example Input

banana
apple
cherry
apple
date

A→Z + Unique Output

apple
banana
cherry
date

Pro Tips

vUse Unique mode to clean up CSS class lists or deduplicate email lists before importing into a CRM.
vSort by Length (Shortest first) to quickly spot the shortest/longest variable names or SQL column values.
vShuffle is useful for randomising test data, creating random assignment lists, or shuffling quiz questions.
vPaste a list of npm package names, sort A->Z, and use the output directly in your package.json or import statements.
vCombine with the Duplicate Remover tool for more control over deduplication options.
What sorting options are available beyond alphabetical?

Alphabetical (A-Z or Z-A): standard dictionary sort, case-sensitive or insensitive. Numeric: sorts by value — 10 comes after 9, unlike alphabetical where 10 comes before 2. By length (shortest to longest or reverse): useful for revealing structure or optimizing CSS selector ordering. Random shuffle: Fisher-Yates algorithm for uniform random order. Reverse current order: flips existing order without re-sorting. Remove empty lines: cleans up lists with blank lines. Trim whitespace: removes leading/trailing spaces from each line before sorting.

When is numeric sort different from alphabetical sort?

Critical difference: alphabetical treats everything as text — "10" sorts before "2" because "1" comes before "2" in ASCII. A list sorted alphabetically: 1, 10, 100, 2, 20, 3. The same list numerically: 1, 2, 3, 10, 20, 100. For pure number lists always use numeric sort. For file names with embedded numbers (file10.txt, file2.txt), natural sort handles this correctly — pad numbers (file002.txt) to make alphabetical match natural order when natural sort is unavailable.

How do I sort lines and remove duplicates simultaneously?

Use the Line Sorter to sort alphabetically, then pass the result to the Duplicate Remover on this site. Or in a terminal: sort -u file.txt sorts and deduplicates in one step. For case-insensitive sort and dedup: sort -f -u file.txt. The -u flag removes exact duplicates after applying the sort comparison, so sort -f -u applies case-insensitive deduplication after case-insensitive sorting.

What is the Fisher-Yates shuffle for random ordering?

Fisher-Yates (also Knuth shuffle) generates a uniformly random permutation. It iterates from end to beginning, swapping each element with a random element at or before its position. This produces a perfectly uniform random permutation — every possible ordering is equally likely. Naive approaches (sorting with Math.random() as comparator) produce biased distributions. Use Fisher-Yates for randomizing test data ordering, quiz questions, playlist shuffles, and A/B test conditions.

How do I sort a list of URLs by domain?

URLs sorted alphabetically group by protocol first (http:// before https://). To sort by domain: extract the domain with a Regex Tester pattern ((?:https?://)?([^/]+)), sort the extracted domains, then reconstruct. Alternatively use sort -t/ -k3 in a terminal to sort by the third slash-delimited field (the domain). The Line Sorter sorts full lines — for field-based sorting, preprocess with regex or command-line tools first.

When would I sort lines by length?

Sort by length is useful for: CSS optimization (shorter selectors are faster to parse), building longest-match rule lists (route patterns, URL patterns), analyzing word frequency distribution, ordering enum values by string length for display, and finding the longest/shortest lines in log output. Sorting by ascending length naturally puts single-word items first and multi-word or long strings last — useful for quick visual scanning of a list structure.

What other text tools are on this site?

The Duplicate Remover removes repeated lines — often used after sorting. The Word Counter counts lines before and after to verify the sort did not drop content. The Text Case Converter normalizes case before case-insensitive sorting. The Regex Tester can extract specific fields from lines for field-based sorting. The Diff Checker shows what changed between original and sorted output. All are in the Dev Tools Text section.

Complete Guide

📊 Key Data Points

Natural sort

Handles item 10 after item 9 — required for filenames, versions, and numbered lists

Trim whitespace

Normalizes leading/trailing spaces before sorting — ensures two spaces before item and item sort together

Deduplicate

Remove duplicate lines — combined with sort brings all duplicates adjacent for efficient removal

Line Sorter — Sort and Deduplicate Text Lines -- Complete USA Guide 2026

Sorting and deduplicating lines of text is a constant task in development — organizing import statements, cleaning up lists, preparing data for comparison. Doing this in a text editor requires manual work; this tool handles it instantly.

This sorter handles alphabetical, numeric, length-based, and natural sort. Runs in your browser.

**Long-tail searches answered here:** line sorter online free, sort lines alphabetically browser no install, sort text lines deduplicate online free.

For deduplication, pair with Duplicate Remover. For comparison, use Diff Checker.

🔬 How This Calculator Works

Sorts lines alphabetically (A-Z or Z-A), numerically, or by line length. Natural sort option handles numbered lists correctly: item 10 sorts after item 9 not after item 1. Case-sensitive and case-insensitive modes. Remove duplicates toggle. Trim whitespace option normalizes leading/trailing spaces before sorting.

✅ What You Can Calculate

Multiple sort modes

Alphabetical, reverse alphabetical, numeric, by line length, and natural sort — covering the most common text sorting needs.

Natural sort for filenames

Natural sort handles item 10 after item 9 rather than after item 1 — standard alphabetical sort breaks filename and version number ordering.

Case-insensitive option

Sort case-insensitively so Apple, banana, and Cherry sort as if they were the same case.

Deduplication built-in

Remove duplicate lines toggle works alongside sorting — sort first, then remove adjacent duplicates.

🎯 Real Scenarios & Use Cases

Organize import statements

Paste your JavaScript import block here, sort alphabetically, and paste back. Sorted imports are easier to diff and review in PRs.

Deduplicate lists

Sort an email list or tag list here to bring duplicates together, then remove them with the deduplication toggle.

Process log files

Sort log lines by timestamp or severity, deduplicate repeated error messages, and paste back for analysis.

Compare sorted lists

Sort two different lists here then compare with Diff Checker to find what is present in one but missing in the other.

💡 Pro Tips for Accurate Results

Natural sort for version lists. 1.9.0 sorts before 1.10.0 with natural sort. Standard alphabetical sort places 1.10.0 before 1.9.0 (because 1 is less than 9 alphabetically). Use natural sort for version numbers, filenames, and IDs.

Sort before deduplicating. When using Remove Duplicates, sort first — duplicates are detected by adjacent line comparison, so unsorted duplicates separated by other lines are not removed.

Organize import statements. Paste your JavaScript import block here, sort alphabetically, and paste back. Sorted imports are easier to diff and review in PRs.

Combine with Diff Checker. Sort two different lists here then compare with Diff Checker to find what is present in one but missing in the other.

🔗 Use These Together

🏁 Bottom Line

Sorting and deduplicating text lines is a repetitive task that comes up constantly in development — organizing imports, cleaning up lists, preparing data. For full text processing: Duplicate Remover and Diff Checker.