Please look at the following code snippet, and the question is presented in the inner foreach loop, which is to ask will the final grouped result keep the original orderby result?
//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???
}
}