Players not ordered by points in tournament view

Before players were ordered by points now they aren’t, e.g. Nine*Nine, NineNineNine

Something’s up


I did a search before doing that same report, but looked for the wrong words! :smile:

Looks like the bug has been addressed, but something still doesn’t work.

In the “Nine*Nine, NineNineNine” tournament

all players are sorted by points… except for the first of the list.

It probably wasn’t addressed. It’s just so happened the pairings go mostly in order sorted by points. Maybe?

You can see how the games go in pairs, right. First some game then the same game but with players reversed. So it’s still ordered by ids.

(my favorite player with fractional number of points)

Pairing players on points and then sorting games on points could probably give that result.

Now that we have a few games completed, we see that players order isn’t changed and the winner isn’t sorted anymore after getting one more point.

Bumping this. Is there any chance this can be tackled soon? This bug means that there is no efficient way to look at tournament standings, which for me takes about 50% out of the fun of playing tournaments.

1 Like

Do we even know where the problem lies?
Is that front end or back end?
It seems to be just a UI feature, so probably front end.

If that’s true we “just” need to find a volunteer for the job! :grin:

1 Like

Here would be a good place to start digging:

Also if anyone wants to create an issue on GitHub, I’d be happy to mark Good First Issue or something (as well as bug obviously :joy:).

1 Like

Looks exactly like the entrance of a rabbit hole! :smile:

Actually I can’t even figure out the meaning of those five lines of code.
Which language is it?

1 Like

Should be javascript /typescript.


Looks like Round Robins use a completely different sorting algorithm and are also broken:

I think that’s just because they sort by points instead of rank.

This sort for top three players based on rank still works though:


Heh I’m not sure it’s particularly illumintating without the context of the rest of the file. But basically, I’m assuming sorted_players (the variable that gets set by setSortedPlayers()) is where our player list is supposed to come from.

It gets sorted using the comparator compareUserRank(), so it’s possible a bug in that function would cause this issue.

(by the way, @shinuito’s right that it’s TypeScript. This file is using React and JSX heavily, so that would explain the extension .tsx and why this doesn’t look like vanilla JS)

1 Like

Oh, look at this, it sets the constant “players” after attempting to sort them:

            const sorted = Object.keys(players)
                .map((id) => players[id])


But compareUserRank() uses the players constant instead of the players that were passed in:

        const pa = players[];
        const pb = players[];
        if (!pa && !pb) {
            return 0;

Looks like it was like that forever though. Maybe it used to run through this update function twice?


I’m quite confused about those “constants” that

I even did an university exam about compiled java but it was many years ago and I don’t recall anything.

I remember that sorting was working some time ago, maybe just some sorting was broken and I didn’t notice it.
Do you know how many distinct sorting algorithms there are?

So far, it looks like two. Here are how the comparisons work for each:

compareUserRank(a, b)

  • check a and b defined
  • compare rank
  • compare points
  • compare sos
  • compare sodos
  • compare ranking
  • compare username

sortDropoutsToBottom(a, b)

  • check if either is Disqualified/Resigned
  • compare points

In this case, we only care about compareUserRank(), and @Feijoa has found the bug. To describe in slightly less technical terms, there is an lookup table called players that is supposed to map ID to a player.

It might look something like this:

id player
308797 { username: “Lys”, points: 4 … }
309835 { username: “Feijoa”, points: 3 …}
427361 { username: “shinuito”, points: 2 …}
568679 { username: “benjito”, points: 1 … }

The function compareUserRank() relies on the players table to be filled with this information. However, the table is empty at the time of sorting, and therefore fails!

I agree, and it’s very hard to pinpoint what change might have caused this. There were a couple large scale changes to that file in the last year (e.g. migration to functional component), but who knows how long the bug has been in there. Maybe some automated testing (currently none on this page) would help catch such bugs when they are introduced.