# 49. Group Anagrams

**<font color=red>难度: Medium</font>**

## 刷题内容

> 原题连接

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

> 内容描述

```
Given an array of strings, group anagrams together.

Example:

Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
Output:
[
  ["ate","eat","tea"],
  ["nat","tan"],
  ["bat"]
]
Note:

All inputs will be in lowercase.
The order of your output does not matter.
```

## 解题方案

> 思路 1

每一个字符串都先排个序看看是不是一样，这样更好判断

```python
class Solution(object):
    def groupAnagrams(self, strs):
        """
        :type strs: List[str]
        :rtype: List[List[str]]
        """
        mapx = {}
        for i in strs:
            tmp = ''.join(sorted(list(i)))
            if tmp in mapx:
                mapx[tmp].append(i)
            else:
                mapx[tmp] = [i]
        return mapx.values()
```
