X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fjs%2Fhelpers%2FParticipant.js;h=8ae225c8570e59845c55891a90ecd2033e4e85b3;hb=ccaa2cf99468fea81efdf28aaa3fc72a278a95f6;hp=af6eecc4d13aedf4f7aba5765a7218a9ee408410;hpb=c59d0714d62f9028135cc9cff829d16b91e5fb4f;p=alttp.git diff --git a/resources/js/helpers/Participant.js b/resources/js/helpers/Participant.js index af6eecc..8ae225c 100644 --- a/resources/js/helpers/Participant.js +++ b/resources/js/helpers/Participant.js @@ -1,3 +1,9 @@ +export const compareUsername = (a, b) => { + const a_name = a && a.user && a.user.username ? a.user.username : ''; + const b_name = b && b.user && b.user.username ? b.user.username : ''; + return a_name.localeCompare(b_name); +}; + export const findResult = (participant, round) => { if (!participant || !participant.user_id) return null; if (!round || !round.results || !round.results.length) return null; @@ -5,5 +11,6 @@ export const findResult = (participant, round) => { }; export default { + compareUsername, findResult, };