Sort / Dedupe Lines
How do I sort lines of text?
Result
How it is calculated
The text is split into lines at every line break (Windows, Mac or Unix style). Three modes are available: asc sorts A to Z, desc sorts Z to A, and unique first drops repeated lines and then sorts what is left in ascending order. Any other mode value falls back to ascending. Sorting is case-insensitive and natural, so digit runs are compared as numbers (item2 comes before item10), and lines that compare equal keep their original relative order. Duplicates are matched exactly, including case and spaces. Empty lines count as lines: a blank line sorts to the top in ascending order, and a trailing line break adds one. Descending order is simply the ascending result reversed.
Worked example
Paste three lines, item10, item2 and item2, and choose the unique mode. Step 1: the second item2 is an exact repeat, so it is removed, leaving item10 and item2. Step 2: the natural sort compares the numbers 2 and 10 rather than the characters, so item2 goes first. The output is:
item2
item10
With a plain character sort, item10 would have come first, because 1 sorts before 2.
Common mistakes
- Expecting duplicates that differ only in case or trailing spaces to be merged.
x,Xandxfollowed by a trailing space are three different lines, so all three survive in unique mode (a second plainxwould be an exact repeat and be dropped); trim and lower-case the text first if you want them merged. - Leaving a blank line at the end of the pasted list. It counts as an empty line and sorts to the very top, so the output starts with an empty row.
- Expecting unique mode to keep the original order. It always returns the unique lines sorted ascending, and the descending option does not apply together with it.
- Assuming accented letters sort as in your language. They are placed by character code, after the plain letters, so a name starting with Ç ends up after Z.
- Sorting a column of numbers and expecting pure numeric order. Only digit runs inside a line are read as numbers; negative signs and decimal points are treated as ordinary characters.
About this calculator
This tool takes a block of text and does one of two things with its lines: sorts them in ascending (A→Z) or descending (Z→A) order, or removes duplicate lines and returns what is left in ascending order. The sort treats A–Z and a–z as equivalent and reads digit runs as numbers, so item9 comes before item10; everything else is compared by character code, which puts accented letters after the unaccented ones rather than where your language would. The duplicate test is stricter: repeats have to match exactly, so a difference in case counts as two lines and both are kept. Either way the tool works line by line on the text itself, not on what the content means — a simple operation, but slow and error-prone to do by hand across more than a handful of lines.
It is used by anyone maintaining lists in plain text — ordering a name list, a set of tags or keywords, or a spreadsheet column pasted as text — and by developers and writers cleaning up data such as a list of URLs, log lines, email addresses or CSV values where duplicate entries have crept in from repeated exports or merges. Removing duplicates before importing a list into a spreadsheet, database or mailing tool avoids double-counting or sending something twice.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
To find out how many repeats a list contained, run it once in ascending mode and once in unique mode, then compare the line counts of the two outputs; the difference is the number of exact duplicates removed. The ascending run also places repeats side by side, which makes near-misses such as a trailing space or a different capital easy to spot by eye. Is it case-insensitive matching or keeping the original order that you would want in unique mode?