Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2016-07-24 21:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (221 votes). Check out past polls.