Rewrote solution so anagrams are sorted into treemap.