I need to find the duplicate items of one column (Qty
) based on another column (Priority
). I have a List that contains the following data:
Priority Product Qty
0 a 10
0 b 20
1 c 50
1 d 20
1 e 50
1 f 10
1 g 20
1 h 10
I need to produce a sorted List<T>
that contains only the duplicates in terms of Qty
among the items with priority 0
.
I.e. the resulting List<T>
would contain:
Priority Product Qty
0 a 10
1 f 10
1 h 10
0 b 20
1 d 20
1 g 20
Is there a simple LINQ/Lambda expression for doing this?
Here is a solution with
GroupBy
: