-1

How can I return multiple item from the list that has the same value? I am using maxBy to return item with the highest value on a property. Highest value is 5 and i know there are two items in the list with that. But it only returns 1 item back. I would like it to return both items.

itemA point = 5, itemB point = 5, itemC point = 4

var teamWithHighestPoint = _unsortedLeagueTable.MaxBy(t => t.Points);
coding1223322
  • 461
  • 11
  • 26

1 Answers1

0

Get all the elements with the maximum score:

var maxPoints = _unsortedLeagueTable.Max(t => t.Points);
var teamWithHighestPoint = _unsortedLeagueTable.Where(t => t.Points == maxPoints);
Tomer
  • 1,606
  • 12
  • 18