counts words in a text and sorts them by occurrence