]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/Tournament.js
add seed display
[alttp.git] / resources / js / helpers / Tournament.js
index 1b808fdf3211f8eede21ee009defb1043db3d4d6..5716e684948b53c84e54262f00d99b553943d755 100644 (file)
@@ -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,
 };