Question Details

No question body available.

Tags

c# performance linq

Answers (1)

January 30, 2026 Score: 0 Rep: 187,576 Quality: Low Completeness: 40%

If second criterium is very expensive, we can use GroupBy to avoid unwanted inner reading:

var sorted = .GroupBy(item => item.Age) .OrderBy(group => group.Key) .SelectMany(group => group.Count()