From d88d44f9e7b8dd039b94d3a6eced18568507fde2 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 5 Dec 2024 15:51:13 -0700 Subject: [PATCH] sort game rankings by kills --- www/index.html | 2 +- www/replay.mjs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/www/index.html b/www/index.html index 3b249ac..d583fb6 100644 --- a/www/index.html +++ b/www/index.html @@ -95,7 +95,7 @@ Name - Score + Kills Death Killer Error diff --git a/www/replay.mjs b/www/replay.mjs index abbb7fe..46912ba 100644 --- a/www/replay.mjs +++ b/www/replay.mjs @@ -182,7 +182,12 @@ class Replay { let tbody = this.results.querySelector("tbody") tbody.replaceChildren() - for (let tank of game.tanks) { + let byKills = Object.keys(game.tanks) + byKills.sort((a, b) => game.tanks[a].kills - game.tanks[b].kills) + byKills.reverse() + + for (let i of byKills) { + let tank = game.tanks[i] let tr = tbody.appendChild(document.createElement("tr")) let tdSwatch = tr.appendChild(document.createElement("td"))