X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fhelpers%2FParticipant.js;h=8545e0335c2f37c9fb854138e1a930211d18648e;hb=d32516335ea2534e15256c948e9c38d3de40794b;hp=d79349bca8776a65ae853943df671f8ffb8f114f;hpb=2b3d5b3d98705cda41a7218d7133234b227e87b6;p=alttp.git diff --git a/resources/js/helpers/Participant.js b/resources/js/helpers/Participant.js index d79349b..8545e03 100644 --- a/resources/js/helpers/Participant.js +++ b/resources/js/helpers/Participant.js @@ -1,28 +1,23 @@ +export const comparePlacement = (a, b) => { + if (a.placement < b.placement) return -1; + if (b.placement < a.placement) return 1; + return compareUsername(a, b); +}; + export const compareResult = round => (a, b) => { const a_result = findResult(a, round); const b_result = findResult(b, round); - const a_time = a_result && !a_result.forfeit ? a_result.time : 0; - const b_time = b_result && !b_result.forfeit ? b_result.time : 0; - if (a_time) { - if (b_time) { - if (a_time < b_time) return -1; - if (b_time < a_time) return 1; - return 0; - } - return -1; - } - if (b_time) { - return 1; - } - const a_forfeit = a_result && a_result.forfeit; - const b_forfeit = b_result && b_result.forfeit; - if (a_forfeit) { - if (b_forfeit) { - return 0; + const a_placement = a_result && a_result.placement ? a_result.placement : 0; + const b_placement = b_result && b_result.placement ? b_result.placement : 0; + if (a_placement) { + if (b_placement) { + if (a_placement < b_placement) return -1; + if (b_placement < a_placement) return 1; + return compareUsername(a, b); } return -1; } - if (b_forfeit) { + if (b_placement) { return 1; } return compareUsername(a, b);