Sorting Words by Frequency in Python

I’ll be honest, it took nearly three hours and about four iterations before I finally figured out how to get this working. What I needed to do was grab N words with the highest value from a list loaded by configparser.

I looked at using a dictionary first, but since dictionaries in Python are unordered, there was no reasonably simple way to sort the dictionary without a lambda statement.

I also looked at namedtuples, a very cool Python feature, but I would have to load the classes into a list to iterate over them. It quickly became too complicated to keep track of everything.

Read moreSorting Words by Frequency in Python