注:sorted()可以排字符串。
class Solution(object):
def groupAnagrams(self, strs):
"""
:type strs: List[str]
:rtype: List[List[str]]
"""
mydict = {}
for item in strs:
temp = ''.join(sorted(item))
if temp in mydict.keys():
mydict[temp].append(item)
else:
mydict[temp]=[item]
res = []
for v in mydict.values():
res.append(v)
return res