请查看以下代码片段,问题显示在内部foreach循环中,即问最终分组结果是否保留原始orderby结果?
//List<Foo> aFooList = ...
aFooList = aFooList.OrderBy(x=>x.A).toList(); //order the list by property A
var groupedResult = aFooList.GroupBy(x=>x.B) //group the list by property B
.OrderBy(x=>x.Count(y=>y!=null)) //Order the group by the group size.
.ToList();
foreach(var group in groupedResult)
{
Debug.WriteLine(group.key);
foreach(var foo in group)
{
//QUESTION: will the foo list here keep the original order which is ordered by property A???
}
}