Hongmu Notes

🗑️ Array deduplication

Paste a set of data, remove duplicates with one click, and retain the order of first occurrence.

Array deduplication

Paste the list into the input box below (separated by spaces, tabs, or newlines), and click "Remove Duplicates" to get the result with duplicates removed.

Instructions for use

  • Spaces, tabs, and newlines are all delimiters, and they can also be used directly when copying an entire column from a table.
  • The results retain the order of first occurrence and are case-sensitive. A and a are treated as two items.
  • The result box is read-only. Click "Copy Results" to remove it. You can also press and hold on your mobile phone to select all and copy them.

Array deduplication

The core rule of array deduplication is "keep only the item that appears for the first time": traverse the data, keep the items you haven't seen before, and throw away the items you have seen. In this way, duplication is removed without disrupting the original order. The results correspond to the original list one-to-one, making it easy to check item by item.

📌 Three rules for removing duplicates

  • Order: Keep the position where it first appears, without sorting.
  • Comparison: Accurate comparison character by character. Different items in capitalization and punctuation are considered different items.
  • White space: spaces, tabs, and newlines are all used as delimiters. Continuous white spaces do not produce empty items.

⚙️ How to use this page

Paste the data into the upper input box, click "Remove Duplication" and the result will appear in the read-only output box below. The status line will tell you how many duplicates have been deleted; if there are no duplicates, it will also clearly prompt that the result is consistent with the input.

✅ Example comparison

inputresult
1 2 3 1 2 31 2 3
a b a c ba b c
苹果 香蕉 苹果苹果 香蕉
A aA a

📌 Why not sort

Deduplication and sorting are two different things: deduplication only cares about whether there are duplicates, and sorting changes the display order. If the two steps are combined, once the result is not as expected, it is difficult to judge whether it is a problem with the deduplication rules or the sorting rules; handle them separately, and only need to check one of the steps when an error occurs.

All keywords and tutorials 12

❓ FAQ

Do I still need to sort manually after deduplication?
Depends on the use. The tool is only responsible for removing duplicates and keeping the order as it is. If you want the results to be sorted alphabetically or numerically, just use the sorting tool to process it once. Doing the two steps separately is more controllable.
Why are there no extra spaces in the results?
Because the tool first merges consecutive blanks, then removes the leading and trailing blanks, and finally splices and outputs a single space. So even if there are extra spaces or empty lines in the input, the result will be clean single-space separation.
Will the elements in the array be automatically sorted?
Will not be sorted. Deduplication is only responsible for discarding duplicate items and retaining the original order. When you need to sort by letters or numerical values, please use a sorting tool to process it again. The results are more controllable if you do it in two steps.