Skip to content

Commit

Permalink
sorting for remote matches sorts by team before match number
Browse files Browse the repository at this point in the history
  • Loading branch information
khari05 committed Dec 1, 2020
1 parent afa6a3f commit aa903b8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/sort.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,16 @@ class Sort {
int tournamentLevel2 = b.tournamentLevel;
int matchNumber1 = int.parse(a.matchKey.split("-")[3].substring(1, 4));
int matchNumber2 = int.parse(b.matchKey.split("-")[3].substring(1, 4));
int matchParticipant1 = int.parse(a.participants[0].teamKey);
int matchParticipant2 = int.parse(b.participants[0].teamKey);
bool isMatchRemote = a.participants.length == 1;

if (tournamentLevel1 == tournamentLevel2) {
/**
* if a match is remote but has already been sorted by team number, it will skip to the next condition: match number.
*/
if (tournamentLevel1 == tournamentLevel2 && isMatchRemote && matchParticipant1 != matchParticipant2) {
return matchParticipant1 < matchParticipant2 ? -1 : 1;
} else if (tournamentLevel1 == tournamentLevel2) {
return matchNumber1 < matchNumber2 ? -1 : 1;
} else if (tournamentLevel1 == MatchType.FINALS_MATCH) {
return 1;
Expand Down

0 comments on commit aa903b8

Please sign in to comment.