Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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


Comment on Re: How to sort IP addresses

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 meditating upon the Monastery: (8)
As of 2014-12-20 02:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls