I have a piece of code that looks like this:
ipCount = defaultdict(int) for logLine in logLines: date, serverIp, clientIp = logLine.split(\" \") ipC
I think this will help you: PEP265 (sorting dictionieries by value). Just extend the sorted function.