List<string> list = new List<string> { "1", "1.1", "1.1.1", "1.1.2", "1.1.3", "1.2", "1.3", "2", "2.1", "2.2", "2.3", "2.3", "1" };
list.Sort((x, y) =>
{
int ret = 0;
var xsplit = x.Split(".".ToCharArray()).Select(z => int.Parse(z)).ToList();
var ysplit = y.Split(".".ToCharArray()).Select(z => int.Parse(z)).ToList();
for (int i = 0; i < Math.Max(xsplit.Count, ysplit.Count); i++)
{
if (xsplit.Count - 1 < i)
{
ret = -1;
return ret;
}
else if (ysplit.Count - 1 < i)
{
ret = 1;
return ret;
}
else
{
ret = xsplit[i] - ysplit[i];
if (ret != 0)
return ret;
}
}
return ret;
});
}