if (! props.player.id)
return null;
+ const sorted_players = [props.player, ...props.other_players].sort((a,b) => {
+ return b.score - a.score;
+ });
+
return (
<div className="player-info">
<span className="players-header">Players: </span>
- {props.player.name}
- {props.player.score > 0 ? ` (${props.player.score})` : ""}
- {props.other_players.map(other => (
- <span key={other.id}>
- {", "}
- {other.name}
- {other.score > 0 ? ` (${other.score})` : ""}
+ {sorted_players.map(player => (
+ <span key={player.id}>
+ {player.name}
+ {player.score > 0 ? ` (${player.score})` : ""}
+ {" "}
</span>
))}
</div>