C# Ranking of objects, multiple criteria

前端 未结 5 879
日久生厌
日久生厌 2020-12-05 12:26

I am building a plugin for a LAN party website that I wrote that would allow the use of a Round Robin tournament.

All is going well, but I have some questions about

5条回答
  •  情话喂你
    2020-12-05 13:16

    This could be a start:

    Dictionary wins = new Dictionary();
    Dictionary score = new Dictionary();
    Dictionary ranks = new Dictionary();
    
    int r = 1;
    
    ranks = (
        from name 
        in wins.Keys 
        orderby wins[name] descending, scores[name] descending
        select new { Name = name, Rank = r++ })
        .ToDictionary(item => item.Name, item => item.Rank);
    

提交回复
热议问题