Sorting anagrams