+export const compareFinished = round => (a, b) => {
+ const a_result = findResult(a, round);
+ const b_result = findResult(b, round);
+ const a_finished = a_result && a_result.has_finished;
+ const b_finished = b_result && b_result.has_finished;
+ if (a_finished) {
+ if (b_finished) {
+ return compareUsername(a, b);
+ }
+ return -1;
+ }
+ if (b_finished) {
+ 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_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_placement) {
+ return 1;
+ }
+ return compareUsername(a, b);
+};
+
+export const compareUsername = (a, b) => {
+ const a_name = getUserName(a);
+ const b_name = getUserName(b);
+ return a_name.localeCompare(b_name);
+};
+