49. Group Anagrams (Medium) - TengnanYao/daily_leetcode GitHub Wiki

class Solution(object):
    def groupAnagrams(self, strs):
        """
        :type strs: List[str]
        :rtype: List[List[str]]
        """
        h = {}
        for s in strs:
            n = "".join(sorted(s))
            h[n] = h.get(n, []) + [s]
        return h.values()