Wiki Home

Sort By IPAddress


Namespace: Wiki
Sort by IP Address:

INDEX ON BINTOC( ;
    VAL(GETWORDNUM(ip_address,1,'.')) * 256^3 + ;
    VAL(GETWORDNUM(ip_address,2,'.')) * 256^2 + ;
    VAL(GETWORDNUM(ip_address,3,'.')) * 256   + ;
    VAL(GETWORDNUM(ip_address,4,'.')) ,8) TAG IP


Or if you want a 4-byte key...

INDEX ON BINTOC( ;
    VAL(GETWORDNUM(ip_address,1,'.')) * 256^3 + ;
    VAL(GETWORDNUM(ip_address,2,'.')) * 256^2 + ;
    VAL(GETWORDNUM(ip_address,3,'.')) * 256   + ;
    VAL(GETWORDNUM(ip_address,4,'.')) - 2^31, 4) TAG IP


Or better yet, if you can assume:
INDEX ON ip_address TAG IP

*this approach is necessary if you want to seek on an IP address (ex. SEEK "192.1.1.1"), but does not put the IPs in proper natural order. "218.13.50.94" would come before "24.14.79.183", for example.

Contributors: Tod Mckenna Ben Creighton
Category Web
( Topic last updated: 2007.06.11 11:07:30 AM )