Skip to content

Commit

Permalink
Ensure ranked votes use the user-specified task ordering, where appli…
Browse files Browse the repository at this point in the history
…cable.
  • Loading branch information
Kinematics committed Jun 22, 2017
1 parent 0a82b01 commit 0b956d3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions NetTally.Core/Output/TallyOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using NetTally.Extensions;
using NetTally.Utility;
using NetTally.ViewModels;
using NetTally.VoteCounting;
using NetTally.Votes;
using NetTally.VoteCounting.RankVoteCounting.Utility;
Expand Down Expand Up @@ -166,8 +167,16 @@ private void ConstructRankedOutput(CancellationToken token)
IRankVoteCounter counter = VoteCounterLocator.GetRankVoteCounter(AdvancedOptions.Instance.RankVoteCounterMethod);
RankResultsByTask results = counter.CountVotes(VoteCounter.GetVotesCollection(VoteType.Rank));

//var orderedRes = results.OrderBy(a => a.Key);
var orderedRes = results;
IOrderedEnumerable<KeyValuePair<string, RankResults>> orderedRes;

if (ViewModelService.MainViewModel.VoteCounter.OrderedTaskList != null)
{
orderedRes = results.OrderBy(v => ViewModelService.MainViewModel.VoteCounter.OrderedTaskList.IndexOf(v.Key));
}
else
{
orderedRes = results.OrderBy(a => a.Key);
}

// Output the ranking results for each task
foreach (var task in orderedRes)
Expand Down

0 comments on commit 0b956d3

Please sign in to comment.