Leaderboard where 90 beats 100
Every score is correct. The ranking puts them in the wrong order anyway.
nodeSoft~12 min
1
Fresh from the oven
Clone it down and have a look around.
$
git clone https://github.com/loaf-crumbs/leaderboard-that-ranks-wrong.git2
The scenario
A small game service backs a leaderboard page. It has one endpoint that returns every player ranked from the highest score to the lowest, and the page renders that list top to bottom.
Every player loads. Every name is right. Every score is right. But the ranking is upside down in a way that doesn't even look like a simple reverse. The board crowns a player who scored 90, while the two clear leaders — one with 110, one with 100 — end up stranded near the bottom. Scores like 8, 9, and 25 are scattered through the middle in an order that makes no numeric sense at all.
Hit the endpoint directly and the same wrong order comes back, so this isn't the browser's fault. There are no errors and no failed requests. The data going in is fine and the data coming out is complete — it's purely the *order* that's wrong. Whatever's happening, it's in the one place that decides who outranks whom.
3
What done looks like
- The leaderboard is ordered by score, highest first (110, 100, 90, 25, 9, 8)
- Every player and every score still appears exactly once — nothing dropped or duplicated
- The ranking is correct for any scores, not just these — two-digit and three-digit scores sort together properly
4
Stuck?
Peek if you need to — they get more specific as you go.
5
Taste test
Send it in when you’re ready. We’ll see if it’s tasty.
When you've got the flag, paste it here.
No attempts yet.