score:6

Accepted answer

if a player name should only appear once you have to group the collection by player and order each group by score. then you can pick the highest 3.

var top3 = scores.groupby(x => x.player)
                 .select(x => x.orderbydescending(y => y.score).first())
                 .orderbydescending(x => x.score)
                 .thenby(x => x.player)
                 .take(3);

score:1

scores.groupby(i => i.player)
      .select(g => g.orderbydescending(s => s.score).first())
      .orderbydescending(i => i.score)
      .thenby(i => i.player)
      .take(3)

but there is a bonus up-vote for any solution that puts the person whose name appears first in the alphabet highest in the event that their scores are tied

thenby is used for tie-breaks on ordering.

idea is to group by player to get each players best score and then process that flat list.

score:4

you can group them and then pick the maximum score of each player, and then order them:

var top3 = scores.groupby(x=>x.player)
                 .select(g=>new 
                         {
                           player=g.key,
                           score=g.max(p=>p.score)
                        })
                 .orderbydescending(s => s.score)
                 .thenby(p=>p.player).take(3);

Related Query

More Query from same tag