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]))
# "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