]> jfr.im git - erebus.git/blobdiff - modules/trivia.py
help - if nofakelag, showcommands should send the list instead of URL
[erebus.git] / modules / trivia.py
index cf67a2a3ca907afad1c226d054b3c2770909828b..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]))
@@ -981,3 +981,14 @@ def spellout(num):
 #              "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
 #              "sixteen", "seventeen", "eighteen", "nineteen", "twenty"
 #      ][num]
+
+
+def topa():
+       answers=__import__('collections').defaultdict(int)
+       for a in (x[1] for x in state.db['questions']['general']):
+                answers[a]+=1;
+       a2=[]
+       for a, num in answers.items():
+               a2.append((a, num))
+       a2.sort(key=lambda v: v[1], reverse=True)
+       return a2