counts instances of words in a document and lists them in ascending order