# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param strs string字符串一维数组 # @return string字符串二维数组 # from collections import defaultdict class Solution: def groupAnagrams(self , strs: List[str]) -> List[List[str]]: # write code here count = defaultdict(list) for i, s in enumerate(strs): # print("".join(sorted(s))) count["".join(sorted(s))].append(s) res = [] for k, v in sorted(count.items(), key=lambda x:len(x[1])): res.append(v) return res