Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How to sort IP addresses

by smahesh (Pilgrim)
on Jan 30, 2007 at 13:19 UTC ( #597358=note: print w/replies, xml ) Need Help??


in reply to How to sort IP addresses

Hi,

We had to do something similar on one of my earlier projects. This was not in Java not Perl. IIRC, the developer basically converted the IPv4 address from the dotted notation(4 octets) to a number (32 bit number - each octet contributing a byte) and just sorted the numbers and converted them back to IPv4 dotted notation.

Maybe you can try the same approach.

Hint: Refer to pack/unpack for the conversion from dotted to number and back.

Regards,
Mahesh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://597358]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2016-12-03 03:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (52 votes). Check out past polls.