From 6bed1844212e03f8d0df89699d474638da36968b Mon Sep 17 00:00:00 2001 From: Thor77 Date: Sat, 2 Jul 2022 15:44:45 +0200 Subject: [PATCH] Really fix sort order --- js/redux/tournamentApi.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/js/redux/tournamentApi.js b/js/redux/tournamentApi.js index 9e20d06..0c792bb 100644 --- a/js/redux/tournamentApi.js +++ b/js/redux/tournamentApi.js @@ -80,7 +80,19 @@ function convertGroup(apiGroup) { return { id: apiGroup.id, number: apiGroup.number, - scores: apiGroup.group_scores.sort((a, b) => b.group_points > a.group_points || b.difference_in_points > a.difference_in_points || b.scored_points > a.scored_points), + scores: apiGroup.group_scores.sort((a, b) => { + if (a.group_points > b.group_points) { return -1 } + else if(a.group_points < b.group_points) { return 1 } + else { + if (a.difference_in_points > b.difference_in_points) { return -1 } + else if (a.difference_in_points < b.difference_in_points) { return 1 } + else { + if (a.scored_points > b.scored_points) { return -1 } + else if (a.scored_points < b.scored_points) { return 1 } + else { return 0 } + } + } + }), matches: apiGroup.matches.sort((a, b) => a.position > b.position).map(match => convertMatch(match, true)) }; }