implemented brute force approach for sorting anagrams next to each other