Skip to content

Commit

Permalink
sort game rankings by kills
Browse files Browse the repository at this point in the history
  • Loading branch information
neale-pnnl committed Dec 5, 2024
1 parent 144d988 commit d88d44f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ <h2>Upload a tank</h2>
<tr>
<th></th>
<th>Name</th>
<th>Score</th>
<th>Kills</th>
<th>Death</th>
<th>Killer</th>
<th>Error</th>
Expand Down
7 changes: 6 additions & 1 deletion www/replay.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit d88d44f

Please sign in to comment.