Sort & Clean Up Lines
runs in your browserSort, shuffle, reverse, deduplicate, trim and number a list of lines. Every step is a toggle, so nothing is lost.
Steps run in order: trim, drop blanks, remove duplicates, sort, reverse, number. Nothing is destructive, so turning a step off brings the lines back.
Input
Result
about this tool
The everyday list jobs
A list arrives from a spreadsheet, a log, or someone's email, and needs tidying before it can be used. This does the common operations in one pass, in a sensible order: trim each line, drop the blank ones, remove duplicates, sort, reverse, then number.
Because the order is fixed and predictable, trimming happens before duplicate
removal — so foo and foo are recognised as the same line rather than
surviving as two.
If the list is still inside a spreadsheet file, the CSV viewer opens it without a spreadsheet application; to change the case of every line first, use the case converter.
Sorting, including the one that works on numbers
Alphabetical sorts using your locale's rules, so accented characters land
where a person would expect rather than after z.
Natural is the one people actually want more often and rarely find. A plain
alphabetical sort puts item10 before item2, because it compares character by
character and 1 precedes 2. Natural sort reads the digits as a number and
orders them item2, item10. Use it for filenames, version strings, invoice
numbers — anything where a number is embedded in text.
Length sorts shortest to longest, handy for spotting the one malformed entry in a column of codes. Shuffle randomises, and is repeatable from the same seed so you can reproduce an order you liked.
Removing duplicates
Duplicate removal keeps the first occurrence of each line and drops the rest, so
the surviving order matches the input. Case sensitive decides whether Apple
and apple are the same line — turn it off for email addresses and human-entered
data, keep it on for identifiers and code.
The counts above the output tell you how many lines went in, how many came out and how many were removed, which is often the answer you came for: how many unique values are in this list.
Numbering
Numbering is applied last, after sorting, and both the starting value and the
separator are configurable. That produces 1. for a Markdown list or 1) for
a document, without a second pass in an editor.
Everything happens in the page, so a list of customer emails or internal hostnames is not uploaded anywhere to be sorted.
To compare two lists rather than clean one, such as the items in one list that are missing from another, use list set operations.
questions
- How do I sort a list so item2 comes before item10?
- Use natural sort. A plain alphabetical sort compares character by character, so 1 precedes 2 and item10 lands before item2. Natural sort reads embedded digits as numbers, which is what you want for filenames, versions and invoice numbers.
- Which duplicate does it keep?
- The first occurrence of each line, so the surviving order matches your input. Lines are trimmed before duplicates are compared, meaning a line with stray spaces is recognised as the same value rather than surviving as a second copy.
- Should case sensitivity be on when removing duplicates?
- Turn it off for email addresses and human-entered data, where Apple and apple are the same value. Keep it on for identifiers, codes and anything from a case-sensitive system.
- How do I count the unique values in a list?
- Turn on remove duplicates and read the counts above the output: lines in, lines out, and how many were removed. The number that came out is your unique count.
- Can I number the lines after sorting?
- Yes. Numbering is applied last, after sorting and deduplication, and both the starting number and the separator are configurable so you can produce '1. ' for Markdown or '1) ' for a document.