fix sorting

This commit is contained in:
Tomáš Mládek 2021-02-11 02:16:12 +01:00
parent 852cfaed2a
commit 179752f35e

View file

@ -192,14 +192,13 @@ def run_forever(address: str, period: int, ssid: str, output: str):
leaderboard_entry = namedtuple('leaderboard_entry', ('name', 'total'))
leaderboard = []
for mac, minutes in leaderboard_tmp.items():
for mac, minutes in sorted(leaderboard_tmp.items(), key=lambda t: t[1], reverse=True):
leaderboard.append(
leaderboard_entry(
mac_to_hostname.get(mac) or mac,
humanize.naturaldelta(timedelta(minutes=minutes))
)
)
leaderboard.sort(key=lambda l: l.total, reverse=True)
leaderboard = leaderboard[:10]
logging.debug(f"Outputting HTML file into {output_file}...")