+ public static function compareResult(Result $a, Result $b) {
+ $a_time = !$a->forfeit ? $a->time : 0;
+ $b_time = !$b->forfeit ? $b->time : 0;
+ if ($a_time) {
+ if ($b_time) {
+ if ($a_time < $b_time) return -1;
+ if ($b_time < $a_time) return 1;
+ return static::compareUsername($a, $b);
+ }
+ return -1;
+ }
+ if ($b_time) {
+ return 1;
+ }
+ if ($a->forfeit) {
+ if ($b->forfeit) {
+ return static::compareUsername($a, $b);
+ }
+ return -1;
+ }
+ if ($b->forfeit) {
+ return 1;
+ }
+ return static::compareUsername($a, $b);
+ }
+
+ public static function compareUsername(Result $a, Result $b) {
+ return strcasecmp($a->user->username, $b->user->username);
+ }
+
+