Sorting IP v4 addresses is a pain. If they are strings, they sort typographically rather than numerically.
If they are [ipaddress] objects, they do the same thing. The [ipaddress] does not have the built in methods that PowerShell would use to sort it, so PowerShell converts it to a string, and then sorts it typographically.
I have in the past come up with a variety of complex ways to do it. Here’s one.
There is an easier way
There is an object which can look like an IP address, which needs to be sorted like an IP address, and whose creators had the foresight to endow it with a .CompareTo() method, which is what PowerShell uses when it sorts things. The [System.Version] object is used to represent file and application versions, and we can leverage it to sort IP addresses simply. We sort on a custom calculation, converting the IP addresses to version objects. The conversion is just for sorting purposes. The output is the original input objects.
The System namespace is the default namespace PowerShell searches for things, so we can leave that out and write it more simply.
Or if we want to go the other way, and avoid aliases and positional parameters, we can say it this way.