IP address sorting

admin

Administrator
Staff member
Hi, I'm not sure if this should go in this section or the database, so I will start here.

I have my table setup, and the php code to display it. However I am running into a problem with properly sorting a field that stores IP address's. It starts out fine. Here is an example.

12.82.174.156
12.83.243.244
128.1.0.73
128.100.86.86
..Snipped for brevity
217.96.2.151
217.96.2.155
24.0.0.203
24.0.121.22
24.0.148.207
38.38.149.222
38.38.50.190
4.1.78.38
4.16.19.102
4.54.86.143
47.129.8.121
47.142.226.49
47.142.231.118
47.142.231.129
47.234.129.113
47.234.132.55
56.0.78.69
56.0.78.83
57.55.133.188
61.0.0.58

See how on the first octet it does not sort the way I want. I dont know of a way to fix this. Could it possibly be my field. Right now it is set to varchar, since it has . in it I cant use integer as a field. Any help would be apprciated.
 
Back
Top