toolready. Sort & Dedupe Lines

Sort & Dedupe Lines

Sort, dedupe, reverse, or shuffle a list of lines.

What this does

Treats the box as a list — one item per line — and rewrites it in place with one of five operations: Sort A → Z, Sort Z → A, Dedupe, Reverse and Shuffle. Two checkboxes, natural/numeric order and case-sensitive, change how lines are compared. A counter under the box tracks total, unique and blank lines as you type. It all happens in the page, so a list of customer emails or internal hostnames is safe to paste.

How do I sort a list of lines alphabetically?

  1. Paste the list, one item per line.
  2. Tick Case-sensitive if upper and lower case should be treated as different.
  3. Click Sort A → Z. The text area is overwritten with the sorted list.
  4. Copy takes the result; Clear empties the box.

Every button edits the text in place and there is no undo, so operations compose — dedupe, then sort, then copy — but a mistaken shuffle costs you the original order.

Why did my numbers sort as 1, 10, 2?

Because plain alphabetical order compares character by character, and the character "1" sorts before "2" regardless of what follows it. Tick Natural / numeric order and digit runs are compared by value instead:

off:  1     on:  1
      10         2
      2          10

off:  file10  on:  file2
      file2        file10

This is the setting you want for filenames, version numbers, ticket IDs and anything else where a number is embedded in text.

Does dedupe keep the first copy or the last?

The first. a b a c b becomes a b c — order is otherwise untouched, so you can dedupe without sorting first. By default the comparison ignores case, so A followed by a leaves only A; tick Case-sensitive and both survive. Note that the "unique" figure in the counter always compares lines exactly, case included, so it can be higher than the number of lines dedupe actually leaves behind.

How are accented and mixed-case lines compared?

Sorting uses your browser's locale-aware collator rather than raw code points, which is why apple, Cherry and banana come out in the order a person would expect instead of with the capital first. A consequence worth knowing: with case-sensitivity off, the comparison ignores accents too, so resume and résumé are treated as equal and keep their original relative order. Sort Z → A is simply the ascending sort reversed, so ties come back in the opposite order rather than staying put.

Why is there a blank line at the top after sorting?

Because your paste ended with a newline, which makes an empty final line — and an empty string sorts before everything else. The blank counter tells you how many such lines exist before you sort. Delete the trailing newline, or run the text through whitespace cleanup to strip empty lines in one pass. Lines are split on both LF and CRLF and rejoined with LF, so a list copied out of a Windows file comes back with Unix line endings. For the next steps on a cleaned list, see find and replace, the case converter, or word and character count.