sort array of anagrams