Mid From PDF LINQ LINQ

How to group and order groups by count descending?

How to group and order groups by count descending?

var groupOrder = employees

.GroupBy(e => e.Department)

.OrderByDescending(g => g.Count());

foreach (var group in groupOrder)

Console.WriteLine($"{group.Key} has {group.Count()} employees");

More from LINQ Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details