GetTopTwoRatedOptions(VoteStorage votes) { var scoredVotes = from vote in votes select new { vote, score = RankingCalculations.LowerWilsonRankingScore(vote) }; var orderedVotes = scoredVotes.OrderByDescending(a => a.score); var topTwo = orderedVotes.Take(2).Select(o => (o.vote, o.score.score)).ToList(); return(topTwo); }
CountVotesForTask(VoteStorage taskVotes) { var results = from vote in taskVotes let wilsonScore = RankingCalculations.LowerWilsonRankingScore(vote) select new { vote, score = wilsonScore }; var orderedResults = results.OrderByDescending(a => a.score.score) .ThenByDescending(a => a.score.count); int r = 1; List <((int rank, double rankScore) ranking, VoteStorageEntry vote)> resultList = new List <((int rank, double rankScore) ranking, VoteStorageEntry vote)>(); foreach (var res in orderedResults) { resultList.Add(((r++, res.score.score), res.vote)); } return(resultList); }