Half the "compare these" tasks in day-to-day work are not code diffs. They are two columns of names, two exports from the same dashboard, or the followers list and the following list of an Instagram account. A real diff tool gives you a wall of plus and minus lines; what you usually want is three short answers: what is only here, what is only there, what is in both.
The shape of the problem
Every list comparison reduces to set operations. If the two lists are clean, the answer is trivial. The work is in the cleaning:
-
Whitespace.
"anna "and"anna"are the same person and two different strings. - Case. Usernames and emails are usually case-insensitive; tags often are not.
- Order. A list sorted by date and a list sorted by name contain the same items and compare as completely different.
- Duplicates. If one side has a name twice, most naive comparisons count it twice.
- Empty lines. Export files are full of them, and they quietly become a "difference".
Instagram exports are the standard example
The follower/following export workflow is a good test, because the files are messy in predictable ways. The export contains header lines, the usernames are not sorted, and the two files are not even in the same format. Before comparing anything, you need to extract just the usernames and normalise them.
Once normalised, the interesting set is the one people actually want: accounts you follow that do not follow back, and the reverse. Both are simple set differences, and both are useless if the normalisation step was sloppy.
Doing it in the browser
For a one-off comparison, a small browser tool is enough and keeps the data local. CompareLists is built around exactly this: paste two lists into two panels, get unique items, overlaps and the combined set, with switches for case sensitivity, whitespace handling, leading zeros and sorting. The comparison runs client-side, which matters when the lists are made of usernames or emails.
A rule worth keeping
Normalise first, compare second, and only then look at the result. Almost every "the tool got it wrong" complaint I have seen about list comparison was really a whitespace or case problem upstream. If the counts look wrong, sort both sides, dedupe both sides, and compare again before blaming the algorithm.
Top comments (0)