The proper way is to use a comparator and generics (as outlined by folks earlier). Note that there is a fallacy of accepting the input data as being absolutely according to what you expect. For example in the case of IPs: 127.0.0.1 and 127.0.0.01 are both accepted by the Java Socket APIs. But the sort that you write should take care of these considerations as well. Therefore I recommend you to use a sorting based on the bytes (octets) of the ip address.
There are a lot of examples doing that and I would not go into that. A simple search would lead you to one on this very website.
What I would do instead is to demonstrate the need to sort by octets:
byte[] ipAddr1 = new byte[] { x1, x2, (byte) 010, x4 };
byte[] ipAddr2 = new byte[] { x1, x2, 9, x4 };
InetAddress addr = InetAddress.getByAddress(ipAddr1);
InetAddress addr = InetAddress.getByAddress(ipAddr2);
Both of these are accepted by the Java Socket library without it reporting any errors. They both work but if you sort it without taking into consideration of the individual octets (do a string sort for example) then the result might not be what you expect. Try it out and see.
For example (if you follow a Collections.sort(list) approach): if you have: "192.160.010.1" and "192.160.9.1". You would see the former appear as less than the latter but that is not true. The reason is that this will do a sort based on strings. That has nothing to do with the structure of an IP address.