Given an array of strings, group together words that are permutations of the same characters. Provide a baseline solution that sorts each word (O(n · m log m), where n is the number of words and m is max word length). Then, under assumptions such as inputs consist only of lowercase 'a'–'z', design an O(n · m) solution using character-frequency hashing. Specify how you construct a stable key (e.g., serialized counts), handle collisions, and analyze time and space trade-offs versus sorting.