你可以用Linq来做。
//test data
List<string> list = new List<string>()
{
"12",
"566",
"10001",
"10",
"templates",
"files"
};
int tempInt;
//filter the numbers from the list and sort
var listNumbers = list.Where(x => int.TryParse(x, out tempInt)).Select(y => Convert.ToInt32(y)).OrderBy(z => z);
//filter the strings from the list and sort
var listStrings = list.Where(x => !int.TryParse(x, out tempInt)).OrderBy(y => y);
//join the two lists again
var orderedList = listStrings.Concat(listNumbers.Select(y => y.ToString())).ToList();
List<Tuple<string, string>> list = new List<Tuple<string, string>>()
{
new Tuple<string, string>("12", "NA"),
new Tuple<string, string>("566", "NA"),
new Tuple<string, string>("10001", "NA"),
new Tuple<string, string>("10", "NA"),
new Tuple<string, string>("templates", "NA"),
new Tuple<string, string>("files", "NA")
};
int tempInt;
//filter the numbers from the list and sort
var listNumbers = list.Where(x => int.TryParse(x.Item1, out tempInt)).Select(y => new Tuple<int, string>(Convert.ToInt32(y.Item1), y.Item2)).OrderBy(z => z.Item1);
//filter the strings from the list and sort
var listStrings = list.Where(x => !int.TryParse(x.Item1, out tempInt)).OrderBy(z => z.Item1);
//join the two lists again
var orderedList = listStrings.Concat(listNumbers.Select(y => new Tuple<string, string>(y.Item1.ToString(), y.Item2))).ToList();