Linq to Objects: does GroupBy preserve order of elements?

.NetLinqGroup By

.Net Problem Overview


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

.Net Solutions


Solution 1 - .Net

Found answer on MSDN: Yes.

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKonstantin SpirinView Question on Stackoverflow
Solution 1 - .NetKonstantin SpirinView Answer on Stackoverflow