don't waste time sorting the characters in the string. Just sequentially count frequencies of them, and compare. An anagram, by definition, would cancel out each other's buckets perfectly.