[Tutor] IP sorting

Grimmtooth grimmtoothtoo@yahoo.com
Wed, 26 Dec 2001 23:23:58 -0500

> All is good, it works well, however it only sorts to the second place of
> the last octet. For example...
> --- 5 hits
> --- 10 hits
> --- 3 hits
> --- 22 hits
> How do I get the to go where it supposed to (at
> the beginning)?

Actually, it *is* sorting to the fourth octet. Look at what you have:


If you asked Python to compare '12' and '120' it would tell you that the
former is 'less' than the latter.  In order to get a true numerical sort,
you need to convert the octets (all of them, not just the fourth) to actual
numbers when sorting.  Or, more kludgey, convert two-digit octets to three
with a leading zero.

Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com