根據值進行排序,查找項目的索引以查找排名,但考慮關係的最佳方法是什麼?第五名的索引可能有兩項,所以第六項被跳過,下一次迭代從第七項開始。通過跟蹤索引來做到這一點是最好的方法嗎?使用linq查找索引位置,但考慮依賴於值的關係
return teamTournamentResults
.OrderByDescending(t => t.RankingPoints)
.Select((item, index) => new { Item = item, Index = index })
.Select(q => new TeamSummaryResultsModel
{
DivisionRanking = q.Index + 1,
RankingPoints= q.Item.RankingPoints,
你見過這個:https://smehrozalam.wordpress.com/tag/ranking-functions/? –
Linq是必需的嗎? – Shekhar