diff --git a/js/components/GroupStage.js b/js/components/GroupStage.js index 2c9791e..a1469e0 100644 --- a/js/components/GroupStage.js +++ b/js/components/GroupStage.js @@ -35,6 +35,18 @@ function ShowMatchesToggleButton(props) { ); } +function sortMatchesByPositionAscending() { + return (a, b) => { + if (a.position < b.position) { + return -1; + } else if (a.position > b.position) { + return 1; + } else { + return 0; + } + }; +} + export class Group extends Component { constructor(props) { super(props); @@ -62,7 +74,7 @@ export class Group extends Component {

Gruppe {this.state.number}

- {this.state.matches.map((match => ( + {this.state.matches.sort(sortMatchesByPositionAscending()).map((match => ( )))} diff --git a/js/components/Match.js b/js/components/Match.js index b80b3f3..d9f3211 100644 --- a/js/components/Match.js +++ b/js/components/Match.js @@ -7,6 +7,7 @@ import {MatchTable} from './MatchTable'; import styles from './Match.module.css'; + export class Match extends React.Component { constructor(props) { super(props); diff --git a/js/redux/tournamentApi.js b/js/redux/tournamentApi.js index e1b9602..e1b37b4 100644 --- a/js/redux/tournamentApi.js +++ b/js/redux/tournamentApi.js @@ -71,16 +71,26 @@ function convertTournament(apiTournament) { } function convertPlayoffStage(apiStage) { - return { - id: apiStage.id, level: apiStage.level, matches: apiStage.matches.sort((a, b) => { + function sortMatchesByPositionAscending() { + return (a, b) => { if (a.position < b.position) { - return -1 + return -1; } else if (a.position > b.position) { - return 1 + return 1; } else { - return 0 + return 0; } - }).map(match => convertMatch(match, false)) + }; + } + + return { + id: apiStage.id, + level: apiStage.level, + matches: apiStage.matches.sort( + sortMatchesByPositionAscending() + ).map( + match => convertMatch(match, false) + ) }; }