Python3    ||   5 lines,  w/ example  ||   T/S 91% / 69%
\nclass Solution:\n    def groupAnagrams(self, strs: list[str]) -> list[list[str]]:\n        \n        anadict = defaultdict(list)     # Ex: ["eat","tea","tan",
```\nclass Solution:\n    def groupAnagrams(self, strs: list[str]) -> list[list[str]]:\n        \n        anadict = defaultdict(list)     # Ex: ["eat","tea","tan","ate","nat","bat"]                     \n        \n        for s in strs:                  #  s   ana  anadict   \n            ana = \'\'.join(sorted(s))    # \u2013\u2013\u2013  \u2013\u2013\u2013  \u2013\u2013\u2013\u2013\u2013\u2013\u2013  \n            anadict[ana].append(s)      # eat  aet  {\'aet\': [\'eat\']}\n                                        # tea  aet  {\'aet\': [\'eat\', \'tea\']}\n                                        # tan  ant  {\'aet\': [\'eat\', \'tea\'], \'ant\': [\'tan\']}\n                                        # ate  aet  {\'aet\': [\'eat\', \'tea\', \'ate\'], \'ant\': [\'tan\']}\n                                        # nat  ant  {\'aet\': [\'eat\', \'tea\', \'ate\'], \'ant\': [\'tan\', \'nat\']}\n                                        # bat  abt  {\'aet\': [\'eat\', \'tea\', \'ate\'], \'ant\': [\'tan\', \'nat\'], \'abt\': [\'bat\']}\n\n        return list(anadict.values())   # [[\'eat\', \'tea\', \'ate\'], [\'tan\', \'nat\'], [\'bat\']]\n```\n\n[https://leetcode.com/problems/group-anagrams/submissions/1453644285/](https://leetcode.com/problems/group-anagrams/submissions/1453644285/)\n\nI could be wrong, but I think that time complexity is *O*(*MN* log *N*) and space complexity is *O*(*N* log *N*), in which *N* ~ length of the longest string and *N* ~ `len(nums)`.
['Python', 'Python3']