Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort by IP Address

Status
Not open for further replies.

BHuffer

IS-IT--Management
Jun 22, 2001
6
US
I have table where I have 1 field name for Ip address. I am trying to perform a sort on that field, and it not working.

For Example after a sort I get the following:

10.10.10.1
10.10.10.129
10.10.10.193
10.10.10.65

Instead of:
10.10.10.1
10.10.10.65
10.10.10.129
10.10.10.193

I also have multiple values for the Second and Third Octets.

If anyone has any idea how this is possible please let me know.

Thanks!!
 
The reason Access is doing that is it performs its sorts on a character basis, from left to right. Therefore:

100.10.10.129 is less than 100.10.10.65
^ ^
|----- sort character -----|

It is performing the sort in this manner because an IP address is a String not a Number.

Unfortunately I dont know how to solve it :-(

You could possibly write some code to do it, but that may take a while.
Alternatively, put each octet in its own field and do a sort on the individual octets.

Hope this helps.

Regards,

Liam Corkhill
 
Mental note.... dont use ASCII diagrams in forum posts....
Sorry new user!! :-(

100.10.10.129 is less than 100.10.10.65 because the "1" in .129 and the "6" in the .65 are being compared. 1 is less than 6, so Access concludes that 100.10.10.129 is less than 100.10.10.65

Hope this makes more sense!!

Regards,

Liam Corkhill

 

Check thread181-97503 for an answer. Terry Broadbent
Please review faq183-874.

"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top