From ff7e5f3ff164a68505733101853357fd04776c21 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 18 Jul 2024 16:18:32 +0200 Subject: [PATCH] sort round matches by index --- tournaments/models/round.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tournaments/models/round.py b/tournaments/models/round.py index c2c6b33..5797f80 100644 --- a/tournaments/models/round.py +++ b/tournaments/models/round.py @@ -44,7 +44,6 @@ class Round(models.Model): else: child_matches = [m for m in child_matches if m.disabled is False] - matches.extend(child_matches) matches.extend(child.ranking_matches(hide_empty_matches)) return matches @@ -62,12 +61,12 @@ class Round(models.Model): else: matches = [m for m in matches if m.disabled is False] + matches.sort(key=lambda m: m.index) + # Recursively fetch matches from child rounds for child_round in self.children.all(): matches.extend(child_round.get_matches_recursive(hide_empty_matches)) - # print(f"{self.name()} > COUNT REC = {len(matches)}") - return matches def root_round(self):