X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fhelpers%2FTournament.js;h=5716e684948b53c84e54262f00d99b553943d755;hb=ccaa2cf99468fea81efdf28aaa3fc72a278a95f6;hp=1b808fdf3211f8eede21ee009defb1043db3d4d6;hpb=c59d0714d62f9028135cc9cff829d16b91e5fb4f;p=alttp.git diff --git a/resources/js/helpers/Tournament.js b/resources/js/helpers/Tournament.js index 1b808fd..5716e68 100644 --- a/resources/js/helpers/Tournament.js +++ b/resources/js/helpers/Tournament.js @@ -1,3 +1,4 @@ +import Participant from './Participant'; import Round from './Round'; export const findParticipant = (tournament, user) => { @@ -18,7 +19,18 @@ export const patchResult = (tournament, result) => { }; }; +export const sortParticipants = tournament => { + if (!tournament || !tournament.participants || !tournament.participants.length) { + return tournament; + } + return { + ...tournament, + participants: tournament.participants.sort(Participant.compareUsername), + }; +}; + export default { findParticipant, patchResult, + sortParticipants, };