Deduplicate Then Sort—or Sort Then Deduplicate?
A controlled comparison showing when cleanup order changes the final list.
Tested 2026-07-18 · Method: 8-line list with case, whitespace, and repeated values · By Dionis Ceban
Bottom line: The safest workflow makes normalization choices explicit, checks a small sample first, and keeps a human review step for meaning-sensitive changes.
Test matrix
| Input or approach | Operation | Observed result |
|---|---|---|
| Deduplicate only | 6 lines | Whitespace variants remain |
| Trim → deduplicate | 5 lines | Exact variants merge |
| Sort → deduplicate | 6 lines | Sorting does not normalize values |
| Trim → deduplicate → natural sort | 5 lines | Clean, predictable final list |
Recommended workflow
- Trim first so invisible edge spaces stop creating false differences.
- Choose whether case should matter before deduplicating.
- Deduplicate before numbering.
- Use natural sort when values contain numbers such as Item 2 and Item 10.
How to reproduce this test
Copy the examples from the matrix into the relevant tool, apply only the named setting, and compare the output character by character. Browser and operating-system differences should not affect these JavaScript text operations.
What this test does not prove
This is a focused behavior test, not a guarantee for every document. Language rules, proprietary file formats, personally identifying data, and search-engine rendering all require context-specific review.