]> jfr.im git - erebus.git/commitdiff
add utility function to trivia module
authorJohn Runyon <redacted>
Thu, 5 Jan 2023 19:19:11 +0000 (13:19 -0600)
committerJohn Runyon <redacted>
Thu, 5 Jan 2023 19:19:11 +0000 (13:19 -0600)
modules/trivia.py

index cf67a2a3ca907afad1c226d054b3c2770909828b..30ec6047060483c5f14bb4840b3a18eb27832452 100644 (file)
@@ -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