Jump to content

Sort IP Addresses


Jacob White
 Share

This topic is 5754 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Welcome Jacob,

The trouble with IP addresses is that a full address is not a number and it's not really appropriate to sort it alphabetically. This makes them difficult to sort either as a regular field or in a value list.

If the IPs are all in the same subnet, then it may be easier to just sort by the last part. If not, it may be necessary to break the IPs into pieces and sort by each piece.

If you can say more about what this is needed for, perhaps someone can offer a good solution or a workaround.

Link to comment
Share on other sites

I am not quite sure how a value list is relevant here.

To sort by IP address, I believe it would be best to convert the IP to a decimal number first, then sort by the calculated field (result is number) =

Let ( [

text = Substitute ( IP ; "." ; " " ) ;

W = LeftWords ( text ; 1 ) ;

R = MiddleWords ( text ; 2 ; 1 ) ;

G = MiddleWords ( text ; 3 ; 1 ) ;

B = RightWords ( text ; 1 )

] ;

B + G * 256 + R * 256^2 + W * 256^3

)

Link to comment
Share on other sites

This topic is 5754 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.