From a0bb0d4f04aaca80b5b8aed4a3e56663de80ccee Mon Sep 17 00:00:00 2001
From: 10756864 <antoine.kryus@etu.utc.fr>
Date: Sun, 16 Oct 2022 15:21:34 +0200
Subject: [PATCH] mod TieBreakFactory() loop order

---
 ia04/comsoc/tieBreak.go | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ia04/comsoc/tieBreak.go b/ia04/comsoc/tieBreak.go
index 4a23935..84acbcd 100644
--- a/ia04/comsoc/tieBreak.go
+++ b/ia04/comsoc/tieBreak.go
@@ -5,18 +5,20 @@ import (
 )
 
 func TieBreakFactory(tieBreakAlts []Alternative) func([]Alternative) (Alternative, error) {
-	return func(alts []Alternative) (Alternative, error) {
+	return func(alts []Alternative) (Alternative, error) {	// alts est la liste de candidats ex-aequo
 		if len(alts) == 0 || alts == nil {
 			return -1, errors.New("002: NullAlternatives")
 		}
 
-		for _, alt := range alts {
-			for _, tieBreakAlt := range tieBreakAlts {
+		for _, tieBreakAlt := range tieBreakAlts {
+			for _, alt := range alts {
 				if alt == tieBreakAlt {
 					return alt, nil
 				}
 			}
 		}
+
+		rank(tieBreakAlts[0], alts)
 		return -1, errors.New("002: NoTieBreakAlternativeFound")
 	}
 }
-- 
GitLab