private List<string> IpOrderBy(List<string> ips) { List<string> ipList = new List<string>(); if (ips != null && ips.Count > 0) { for (int i = 0; i < ips.Count; i++) { var ip = ips[i]; ip = Regex.Replace(ip, "(\d+)", "00$1"); ip = Regex.Replace(ip, "0*(\d{3})", "$1"); ips[i] = ip; } var ts = new SortedSet<string>(ips); foreach (var ip in ts) ipList.Add(Regex.Replace(ip, "0*(\d+)", "$1")); } return ipList; }