c#让字符串按数字排序问题
// An highlighted block
class SortByNum : IComparer<string>
{
public int Compare(string x, string y)
{
int numX;
int.TryParse(removeNotNumber(x),out numX);
int numY;
int.TryParse(removeNotNumber(y), out numY);
return (numX.CompareTo(numY));
}
public static string removeNotNumber(string key)
{
return Regex.Replace(key, @"[^\d]*", "");
}
}