get items from a list by checking the priority of another list using linq

But I’m wondering this can be done with a single LINQ query

var priorityItems = list
    .GroupBy(x => x.Group)
    .Where(grp => groupPririties.Contains(grp.Key))
    .OrderBy(grp => groupPririties.IndexOf(grp.Key))

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top