views:

127

answers:

1

Does Enumerable.GroupBy from LINQ to Objects preserve order of elements in the groups?

+8  A: 

Found answer in MSDN: yes.

The IGrouping objects are yielded in an order based on the order of the elements in source that produced the first key of each IGrouping. Elements in a grouping are yielded in the order they appear in source.

Konstantin Spirin