Here's the idea: two strings are anagrams if and only if they have the same letters. So give each string a "canonical form" that's identical for all anagrams.
The simplest canonical form is the sorted string. "eat" becomes "aet". "tea" becomes "aet". Same key means same group.
Use this sorted form as a hash map key. As you iterate through strings, compute each one's sorted form and add it to the corresponding group.
You're turning an comparison problem into an grouping problem by using hash map lookups.