分组排序-按X分组,将总结果数量少的排在前面
List<string> arr = new List<string>();
arr.Add("X01-Y01");
arr.Add("X01-Y02");
arr.Add("X01-Y03");
arr.Add("X02-Y01");
arr.Add("X02-Y02");
var results = arr.GroupBy(t => t.Substring(0, 3)).OrderBy(t => t.Count()).ToList()[0].ToList();
List<string> list = results;
运行结果
多级排序,优先第一列排序,其次第二列排序
int[] qq1 = { 1117, 9 };
int[] qq2 = { 1116, 3 };
int[] qq3 = { 1116, 1 };
int[] qq4 = { 1117, 7 };
int[] qq5 = { 1115, 5 };
int[][] prr = { qq1, qq2, qq3, qq4, qq5 };
int[][] stuList = prr.OrderBy(s => s[0]).ThenBy(s => s[1]).ToArray();
运行结果