我有下面的代码填充列表。
List<Person> people = new List<Person>();
for (int i = 1; i <= 30; i++)
{
var p = new Person();
if (i <= 10) p.Group = "A";
else if (i <= 20) p.Group = "B";
else p.Group = "C";
p.Name = "Person " + i;
if (i % 3 == 0)
p.Age = 10;
else
p.Age = 20;
people.Add(p);
}
现在我想按以下顺序进行排序:所有人必须是第一个具有“B”组的人,并且必须按年龄排序。然后其他人必须按年龄排列,组不必按顺序排列。这是示例:
Name Group Age
Person B 10
Person B 10
.....
Person B 20
Person B 20
Person B 20
.....
//From here Group doesn't have to be in order.
Person A 10
Person A 10
.....
Person C 10
Person C 10
.....
Person A 20
Person A 20
Person A 20
.....
Person C 20
Person C 20
Person C 20
....
我可以用一个 linq 查询来做到这一点吗?
谢谢您的帮助!