https://github.com/Skinney/WordSorter C version.