A good strategy would be to implement a histogram as a Python dict. The keys would be the words, and the values would be the count of each word.
After all the words have been counted within a for loop, you could then sort the result of calling .items() on the dict. Sort the words according to their count.
You can then loop through the sorted words, as appropriate, to create the table.
Please give it a try, and post your code, so we can help.