From 2f40091c6fd94d5e35ce80565477b3c49ccc692b Mon Sep 17 00:00:00 2001 From: Wolvan Date: Sat, 29 Jan 2022 22:16:41 +0100 Subject: [PATCH] Sort entries by votes The entries on the result page are now ordered by the amount of votes they got. This should make discerning a winner much easier. --- src/frontend.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend.ts b/src/frontend.ts index c0c783d..303abd1 100644 --- a/src/frontend.ts +++ b/src/frontend.ts @@ -124,7 +124,7 @@ export default function init(router: Router): void { ).then(r => r.json()) as PollResult; if (!poll || poll.error) return res.redirect("/"); const totalVotes = Object.values(poll.votes).reduce((acc, cur) => acc + cur, 0); - const pollOptionsDivs = Object.entries(poll.votes).map(([option, votes]) => ` + const pollOptionsDivs = Object.entries(poll.votes).sort((a, b) => b[1] - a[1]).map(([option, votes]) => `
${ xss(option) }
${ votes }