Linq/Lambda OrderBy Delegate for List of IP Addresses

Given List ips = new List();

I need to sort the list of IP addresses in a logical order (i.e. "192.168.0.2" comes before "192.168.0.100").

Currently (and correctly, alphabetically) if the list contains:

192.168.0.1
192.168.0.2
192.168.0.10
192.168.0.200

ips.OrderBy(p => p) returns:

192.168.0.1
192.168.0.10
192.168.0.2
192.168.0.200
15
задан lukiffer 24 January 2011 в 17:47
поделиться