From: Carl Worth Date: Thu, 18 Jun 2020 16:14:25 +0000 (-0700) Subject: Sort player list by overall scores X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=commitdiff_plain;h=9e08b1b85cc467336129e22bc0ece6dfe74d204e Sort player list by overall scores Making it that much easier to see who is in the lead --- diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index e67bbc8..82bb5ff 100644 --- a/empathy/empathy.jsx +++ b/empathy/empathy.jsx @@ -205,16 +205,18 @@ const PlayerInfo = React.memo(props => { if (! props.player.id) return null; + const sorted_players = [props.player, ...props.other_players].sort((a,b) => { + return b.score - a.score; + }); + return (
Players: - {props.player.name} - {props.player.score > 0 ? ` (${props.player.score})` : ""} - {props.other_players.map(other => ( - - {", "} - {other.name} - {other.score > 0 ? ` (${other.score})` : ""} + {sorted_players.map(player => ( + + {player.name} + {player.score > 0 ? ` (${player.score})` : ""} + {" "} ))}