class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& strs) {
//整体还是基于排序的思路
unordered_map<string,vector<string>>map;
vector<vector<string>>res;
for(auto & str:strs){
string temp=str;
sort(str.begin(),str.end());
map[str].push_back(temp);
}
for(auto it=map.begin();it!=map.end();++it){ //注意这里的it不能用&
res.push_back(it->second);
}
return res;
}
};