G
Guest
Trying to sort a list of IP addresses by the 3rd octet? Any Suggestions?
Thanks,
Jim
Thanks,
Jim
....jf said:For example I have:
172.21.34.82
172.21.48.80
172.21.48.83
172.22.42.100
172.22.42.101
172.24.10.15
172.24.10.16
172.24.102.12
172.24.14.15
As those with a very slight understanding of what IP addresses are
might have noticed from this sample (and should have known before
responding), octets should be treated as numbers. Therefore, the 2nd
to last IP address with 3rd octet 102 should be sorted last (in
ascending order), not 3rd, which it would be with simplistic text
parsing.
What you need is to pull the 3rd octets into a separate column AS
NUMBERS, and sort on that column. The general way to isolate the 3rd
octet in x is with a formula like
=INT(--MID(x,FIND(CHAR(127),SUBSTITUTE(x,".",CHAR(127),2))+1,3))
Frank Kabel said:though I like your solution idea this may not work in non-English
countries. e.g. for the following IP address
172.24.1.12
your formula returns a date value ("1-Jan-2004") if the dot is used for
delimiting the date parts.
Part of me wants to respond that continental Europe has lost whatever
contest there may have been to establish computer and IP standards,
and the sooner y'all recognize that '.' is the decimal point and ','
the thousands separator, and '/' or '-' date component separators,
the better for all.
However, I'll address your point. If you live in some backwards
region that doesn't use US-standard settings by default, and you need
to work with data using US-standard separators (such as the .s in IP
addresses), then change those US-standard separators to your local
separators as the initial step.
=INT(--MID(SUBSTITUTE(x,".",","),
FIND(CHAR(127),SUBSTITUTE(x,".",CHAR(127),2))+1,3))
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.