I have a piece of code that looks like this:
ipCount = defaultdict(int)
for logLine in logLines:
date, serverIp, clientIp = logLine.split(" ")
ipCount[clientIp] += 1
for clientIp, hitCount in sorted(ipCount.items), key=operator.itemgetter(0)):
print(clientIp)
and it kind of sorts IP's, but like this:
192.168.102.105
192.168.204.111
192.168.99.11
which is not good enough since it does not recognize that 99 is a smaller number than 102 or 204. I would like the output to be like this:
192.168.99.11
192.168.102.105
192.168.204.111
I found this, but I am not sure how to implement it in my code, or if it is even possible since I use dictionary. What are my options here? Thank you..
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…