linq - In C#, how can I order a list after its grouped by size of the list? -
lets have collection of car objects
3 blue cars
10 yellow car
5 red cars
list<car> cars = getlist(); var groupby = cars.groupby(r=>r.color); i want sort groupby grouped collection in descending order first yellow cars, red , blue when loop through list
what correct way sort grouped list size of collection in entry of group list?
var result = cars.groupby(r=>r.color).orderbydescending(g => g.count());
Comments
Post a Comment