Name the key first
transcript
Two strings can look different. They can still be the same kind. Egg and add have different letters. Yet their patterns agree. Name a key, and a map does the rest.
Replace each letter by its first place. Egg reads zero, one, one. Add reads zero, one, one too. So does foo. Bar reads zero, one, two. It forms its own group.
Compute the key for each item. Look the key up in a map. Add the item to that group. One pass is enough.
A weak key joins groups that should stay apart. Test every key on near neighbours before you trust it.
Items of the same kind get the same key. They meet in one group. Items of another kind get another key. They never mix. So one map holds every group, built in one pass.
Write the key before any code. Members share it. Other groups never do. Test it on near neighbours. Full breakdown in the lecture.