# 给定一个字符串数组，将字母异位词组合在一起。字母异位词指字母相同，但排列不同的字符串
class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        # from collections import defaultdict
        res={}

        for s in strs:
            alpha_s=str(sorted(s))
            if alpha_s in res:
                res[alpha_s].append(s)
            else:
                res[alpha_s]=[s]
        
        return list(res.values())
        

e2d4b47b2e53396b318ea1439b9380e0eacdc8d8
<mask token>

class Solution:
    <mask token>

class Solution:

    def groupAnagrams(self, strs: List[str]) ->List[List[str]]:
        res = {}
        for s in strs:
            alpha_s = str(sorted(s))
            if alpha_s in res:
                res[alpha_s].append(s)
            else:
                res[alpha_s] = [s]
        return list(res.values())

# 给定一个字符串数组，将字母异位词组合在一起。字母异位词指字母相同，但排列不同的字符串
class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        # from collections import defaultdict
        res={}

        for s in strs:
            alpha_s=str(sorted(s))
            if alpha_s in res:
                res[alpha_s].append(s)
            else:
                res[alpha_s]=[s]
        
        return list(res.values())
        
