Added shared sort method, deduplicated appending code in anagram searches