Modified the way that words are sorted

Needs testing and fixing; also a reference to the paper I saw the idea
from (Zaks def 1)