diff --git a/tournaments/models/round.py b/tournaments/models/round.py index a7dee08..befe57a 100644 --- a/tournaments/models/round.py +++ b/tournaments/models/round.py @@ -67,10 +67,7 @@ class Round(models.Model): matches.sort(key=lambda m: m.index) # Recursively fetch matches from child rounds - # Sort children by depth in ascending order (deeper rounds last) - sorted_children = sorted(self.children.all(), key=lambda child: (child.index, child.get_depth())) - - for child_round in sorted_children: + for child_round in self.children.all(): matches.extend(child_round.get_matches_recursive(hide_empty_matches)) return matches diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index ff4d12b..d8782a0 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -469,7 +469,13 @@ class Tournament(models.Model): ranking_matches = [m for m in ranking_matches if m.disabled is False] if len(ranking_matches) > 0: - ranking_matches.sort(key=lambda m: m.index) + ranking_matches.sort( + key=lambda m: ( + m.round.index, # Sort by Round index first + m.round.get_depth(), + m.name, # Then by Round depth + ) + ) group = self.create_match_group('Matchs de classement', ranking_matches) groups.append(group)