Q:

linq orderby with some condition

I'm trying to sorting groups by active players...
In this case, the first group contains the biggest players inside:
List<Group> groups = tournament. Groups. OrderByDescending(o => o.Players. Count).ToList();

I have to add an filter that will count only active players, Something like this:
if (o.Players[index].Active == true)
    count Players[index] into o.Players. Count

Can someone help me with the syntax? 

A:

you can use this :
List<Group> groups = tournament. Groups
                    .OrderByDescending(o => o.Players. Count(P => P.Active)).ToList();

