We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9fd9427 commit d08f55bCopy full SHA for d08f55b
1 file changed
abiflib/irv_tally.py
@@ -311,9 +311,16 @@ def IRV_dict_from_jabmod(jabmod):
311
canddict = retval['canddict'] = jabmod['candidates']
312
candlist = list(jabmod['candidates'].keys())
313
votelines = jabmod['votelines']
314
+
315
(retval['winner'], retval['rounds'], retval['roundmeta']) = \
316
_irv_count_internal(candlist, votelines, roundnum=1)
317
318
+ # Sort candidate keys in each round by descending order of topranks
319
+ if retval['rounds']:
320
+ for idx, round_dict in enumerate(retval['rounds']):
321
+ sorted_items = sorted(round_dict.items(), key=lambda item: item[1], reverse=True)
322
+ retval['rounds'][idx] = {k: v for k, v in sorted_items}
323
324
winner = retval['winner']
325
if len(winner) > 1:
326
winnerstr = " and ".join(canddict[w] for w in sorted(winner))
0 commit comments