“Sort an array of strings so that all the anagrams are next to each other”

Surely, with the knowledge that strings are char arrays, and knowing that each char can be cast into an int equal to its Ascii code, then all you need to do is sort this array accordingly?
It seems to work!
If you use std::sort you can use a lambda too, as this seems to be the trendy way of doing things since C++ 11.