By sorting and adding into hashset
Intuition: Categorize by sorting\njava []\nclass Solution {\n    public List<List<String>> groupAnagrams(String[] strs) {\n        Map<String, List<String>> map
# Intuition: Categorize by sorting\n```java []\nclass Solution {\n    public List<List<String>> groupAnagrams(String[] strs) {\n        Map<String, List<String>> map = new HashMap<>();\n        \n        for (String str : strs) {\n            char[] charArray = str.toCharArray();\n            Arrays.sort(charArray);\n            String sortedStr = new String(charArray);\n            if (!map.containsKey(sortedStr)) {\n                map.put(sortedStr, new ArrayList<>());\n            }\n            map.get(sortedStr).add(str);\n        }\n        \n        return new ArrayList<>(map.values());\n    }\n}\n```\n```python []\nclass Solution:\n    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:\n        dic={}\n        k=[]\n        for i in strs:\n            l="".join(sorted(i))\n            dic.setdefault(l,[]).append(i)\n      \n        return dic.values()\n```\n\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach:\nbrute force approach ;we solve this by using two for loops by iterating one and the other and one while loop to find the array[i]and array[j] is a anagram \nbut it takes O(n**2) time complexity \n The Next approach is by sorting :\n1)create a dictionary  iterate the for loop(i from 0,len(array)) and chech whether the sorted of arr[i] in dict or not if not .Add the arr[i] to the dic with key (arr[i].sort) and  value as arr[i]in a list \n2)if it exists add the arr[i]\n![group.jpg](https://assets.leetcode.com/users/images/a899c3fb-b525-46a9-acfd-3e70f7eb2083_1707831345.47533.jpeg)\n       FINALLY RETURN THE VALUES OF DIRECTORY\n METHOD2: WE CAN SOLVE THIS PROBLEM BY USING FREQUENCY AS THE ABOVE DIAGRAM GIVEN \n\n\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(nlogK) k is the length of largest string\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:\n        dic={}\n        k=[]\n        for i in strs:\n            l="".join(sorted(i))\n            dic.setdefault(l,[]).append(i)\n      \n        return dic.values()\n        \n\n            \n\n        \n```
['Python', 'Java', 'Python3']