'Called by comparison operations.
Should return a negative integer if self < other, zero if self
== other, a positive integer if self > other.
Order is first determined by the address family. IPv4 addresses
are always smaller than IPv6 addresses:
>>> IP(\'10.0.0.0\') < IP(\'2001:db8::\')
1
Then the first address is compared. Lower addresses are
always smaller:
>>> IP(\'10.0.0.0\') > IP(\'10.0.0.1\')
0
>>> IP(\'10.0.0.0/24\') > IP(\'10.0.0.1\')
0
>>> IP(\'10.0.1.0\') > IP(\'10.0.0.0/24\')
1
>>> IP(\'10.0.1.0/24\') > IP(\'10.0.0.0/24\')
1
>>> IP(\'10.0.1.0/24\') > IP(\'10.0.0.0\')
1
Then the prefix length is compared. Shorter prefixes are
considered smaller than longer prefixes:
>>> IP(\'10.0.0.0/24\') > IP(\'10.0.0.0\')
0
>>> IP(\'10.0.0.0/24\') > IP(\'10.0.0.0/25\')
0
>>> IP(\'10.0.0.0/24\') > IP(\'10.0.0.0/23\')
1'

def __cmp__(self, other):

    if (not isinstance(other, IPint)):
        raise TypeError
    if (self._ipversion != other._ipversion):
        return (((self._ipversion < other._ipversion) and (-1)) or 1)
    if (self.ip != other.ip):
        return (((self.ip < other.ip) and (-1)) or 1)
    if (self._prefixlen != other._prefixlen):
        return (((self._prefixlen < other._prefixlen) and (-1)) or 1)
    return 0
