can't use lambdas/closures in cython functions
@@ -134,13 +134,16 @@ cpdef bint check_global(bot: object, ctx: object):
return True
+cdef signed int lb_logic_sort_key(e: object):
+ return e[1]
+
cpdef str lb_logic(self: object, lb_list: list, u_entry: tuple, rank_fstr: str):
# add user entry to leaderboard if it's not there already
if u_entry is not None and u_entry[0] not in [e[0] for e in lb_list]:
lb_list.append(u_entry)
# sort
- lb_list = sorted(lb_list, key=(lambda e: e[1]), reverse=True)
+ lb_list = sorted(lb_list, key=lb_logic_sort_key, reverse=True)
# shorten list
lb_list = lb_list[:9] if (u_entry is not None and u_entry[2] > 9) else lb_list[:10]
