"""
https://leetcode.com/problems/group-anagrams/
"""

from typing import List


class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        group = {}
        for s in strs:
            sList = list(s)
            sList.sort()
            sTmp = ''.join(sList)
            if sTmp in group:
                group[sTmp].append(s)
            else:
                group[sTmp] = [s]
        return list(group.values())

"""
https://leetcode.com/problems/group-anagrams/
"""

from typing import List


class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        group = {}
        for s in strs:
            sList = list(s)
            sList.sort()
            sTmp = ''.join(sList)
            if sTmp in group:
                group[sTmp].append(s)
            else:
                group[sTmp] = [s]
        return list(group.values())

https://leetcode.com/problems/group-anagrams/