class Solution {
public List<List<String>> groupAnagrams(String[] strs) {
List<List<String>> lists = new ArrayList<>();
//多个list列表————map(排序之后判断key)
Map<String,List<String>> map = new HashMap<>();
for (String str : strs) {
char[] chars = str.toCharArray();
Arrays.sort(chars);
String s = String.valueOf(chars);
List<String> list = map.getOrDefault(s,new ArrayList<>());
list.add(str);
map.put(s,list);
}
return new ArrayList<List<String>>(map.values());
}
}