Hash strings by their sorted characters or character frequency tuples as keys, grouping matching anagrams in a hash map.