Group phrases that are anagrams, ignoring case and symbols
A word-game app lets players submit phrases, and the moderation screen clusters submissions that are anagrams of each other, so “Dormitory” and “dirty room!” land together. Implement groupPhraseAnagrams(phrases), which groups phrases that are anagrams.
groupPhraseAnagrams(phrases) // => string[][]
A–Z and a–z count. Ignore every other character: spaces, punctuation, digits, emoji, and accented letters.'A' and 'a' are the same letter.'42' or '!!').phrases. An empty array returns [].groupPhraseAnagrams([
'Listen', 'Google', 'Silent!', 'Dormitory', '42', 'enlist', 'dirty room', 'Inlets', 'Go, ogle',
]);
// => [
// ['Listen', 'Silent!', 'enlist', 'Inlets'],
// ['Google', 'Go, ogle'],
// ['Dormitory', 'dirty room'],
// ]