Reimplementing LINQ to Objects: Part 26a – IOrderedEnumerable
Implementing OrderBy/OrderByDescending/ThenBy/ThenByDescending isn’t too bad, once you understand how the pattern works, but that’s a slight conceptual leap. I’ll take it one step at a time, first introducing some extra infrastructure (both public and internal), then implementing it simply and slowly, and finally optimizing it somewhat. The sorting features of LINQ As a query language, it’s natural that LINQ allows you to sort sequences. Of course, collections have had the ability to sort their contents since v1.0 but LINQ is different in various ways: It expects you’ll usually want to sort via projections, rather than on a "natural" comparison of … Continue reading Reimplementing LINQ to Objects: Part 26a – IOrderedEnumerable