public class Test {
public static void main(String[] args) {
String temp = "122.158.1.28 14.11.16.10 4.4.72.3 127.0.0.11";
temp = temp.replaceAll("(\\d+)", "00$1");
temp = temp.replaceAll("0+(\\d{3})", "$1");// 将ip地址补成同样位数
String[] str = temp.split(" +");
Arrays.sort(str);
for (String s : str)
System.out.println(s.replaceAll("0+(\\d+)", "$1"));
}
}