public static IEnumerable <RankGroupedVoters> GroupByVoteAndRank(GroupedVotesByTask task) { var res = task.GroupBy(vote => VoteString.GetVoteContent(vote.Key), Agnostic.StringComparer) .Select(votes => new RankGroupedVoters { VoteContent = votes.Key, Ranks = from v in votes group v by VoteString.GetVoteMarker(v.Key) into vr select new RankedVoters { Rank = int.Parse(vr.Key), Voters = vr.SelectMany(a => a.Value) } }); return(res); }
/// <summary> /// Gets all choices from all user votes. /// </summary> /// <param name="task">The collection of user votes.</param> /// <returns>Returns a list of all the choices in the task.</returns> public static List <string> GetAllChoices(GroupedVotesByTask task) { var res = task.GroupBy(vote => VoteString.GetVoteContent(vote.Key), Agnostic.StringComparer).Select(vg => vg.Key); return(res.ToList()); }