[games/chessament] src/tournament: Fix order of byes

Manuel Alcaraz Zambrano <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 284b44a4ad00c6fa354729015b801279fc81e069 by Manuel Alcaraz Zambrano.
Committed on 07/08/2026 at 10:40.
Pushed by manuelal into branch 'master'.

Fix order of byes

M  +16   -1    src/tournament/tournament.cpp

https://invent.kde.org/games/chessament/-/commit/284b44a4ad00c6fa354729015b801279fc81e069

diff --git a/src/tournament/tournament.cpp b/src/tournament/tournament.cpp
index 62c7a91..32b59b5 100644
--- a/src/tournament/tournament.cpp
+++ b/src/tournament/tournament.cpp
@@ -12,6 +12,7 @@
 
 #include "db.h"
 #include "event.h"
+#include "pairing.h"
 #include "ratinglists/ratinglist.h"
 #include "state.h"
 #include "tiebreaks/points.h"
@@ -824,7 +825,21 @@ std::expected<void, QString> Tournament::sortPairings(std::optional<int> round)
                 if (a->whiteResult() == b->whiteResult()) {
                     return a->whitePlayer()->startingRank() < b->whitePlayer()->startingRank();
                 }
-                return std::to_underlying(a->whiteResult()) > std::to_underlying(b->whiteResult());
+
+                static const QList<Pairing::PartialResult> byesOrder{
+                    Pairing::PartialResult::PairingBye,
+                    Pairing::PartialResult::FullBye,
+                    Pairing::PartialResult::HalfBye,
+                    Pairing::PartialResult::ZeroBye,
+                };
+
+                const auto aOrder = byesOrder.indexOf(a->whiteResult());
+                Q_ASSERT(aOrder >= 0);
+
+                const auto bOrder = byesOrder.indexOf(b->whiteResult());
+                Q_ASSERT(bOrder >= 0);
+
+                return aOrder < bOrder;
             }
             if (aRank == 0) {
                 return false;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.