Here's an alternative approach:
var items = new List<Tuple<string, int>>() { Tuple.Create("A", 3), Tuple.Create("A", 5), Tuple.Create("B", 1), Tuple.Create("C", 1), Tuple.Create("C", 3), Tuple.Create("C", 2) }; var results = items.GroupBy(i => i.Item1) .SelectMany(g => g .Where(i => i.Item2 == g.Max(m => m.Item2))) .Distinct(); Or if you prefer using the C# LINQ syntax:
results = (from item in items group item by item.Item1 into groupedItems let maxPriority = groupedItems.Max(item => item.Item2) from element in groupedItems where element.Item2 == maxPriority select element;element).Distinct();