]> jfr.im git - erebus.git/commitdiff
trivia - add tie-breaker for target votes with no winner: lowest target wins
authorJohn Runyon <redacted>
Mon, 8 May 2023 07:05:16 +0000 (02:05 -0500)
committerJohn Runyon <redacted>
Mon, 8 May 2023 07:05:16 +0000 (02:05 -0500)
modules/trivia.py

index 30ec6047060483c5f14bb4840b3a18eb27832452..af0ff7fb1c4a8c571d4d045ca19fa7a4cd9edf1b 100644 (file)
@@ -271,7 +271,7 @@ class TriviaState(object):
 
        def endPointVote(self):
                self.getchan().msg("Voting has ended!")
-               votelist = sorted(self.voteamounts.items(), key=lambda item: item[1]) #sort into list of tuples: [(option, number_of_votes), ...]
+               votelist = sorted(self.voteamounts.items(), key=lambda item: (item[1], -item[0])) #sort into list of tuples: [(option, number_of_votes), ...]
                for i in range(len(votelist)-1):
                        item = votelist[i]
                        self.getchan().msg("%s place: %s (%s votes)" % (len(votelist)-i, item[0], item[1]))