Skip to content
Permalink
Browse files

Roll out some spaceships

  • Loading branch information...
flack committed Jul 26, 2019
1 parent d37901a commit e040bea33381deaecfce39029d23b71caf55c450
@@ -36,6 +36,6 @@ public function get_sorted_list()
*/
private function sort_cmp($a, $b)
{
return (($a[MIDCOM_NAV_SCORE] < $b[MIDCOM_NAV_SCORE]) ? 1 : -1);
return $b[MIDCOM_NAV_SCORE] <=> $a[MIDCOM_NAV_SCORE];
}
}
@@ -519,6 +519,6 @@ public function sort_schema_fields($first, $second)
break;
}
$fields = $this->_config->get('object_' . $type . '_fields');
return (array_search($first, $fields) < array_search($second, $fields)) ? -1 : 1;
return array_search($first, $fields) <=> array_search($second, $fields);
}
}
@@ -84,12 +84,9 @@ public function get_history()
usort($entries, function ($a, $b) {
if ($a['timestamp'] == $b['timestamp']) {
if ($a['order'] == $b['order']) {
return 0;
}
return ($a['order'] > $b['order']) ? -1 : 1;
return $b['order'] <=> $b['order'];
}
return ($a['timestamp'] > $b['timestamp']) ? -1 : 1;
return ($b['timestamp'] <=> $a['timestamp']);
});
return $entries;
@@ -201,9 +201,9 @@ private function _sort_by_time($a, $b)
$ap = $a['sort_time'];
$bp = $b['sort_time'];
if ($this->_sort == 'reverse') {
return $bp - $ap;
return $bp <=> $ap;
}
return $ap - $bp;
return $ap <=> $bp;
}
/**
@@ -99,10 +99,7 @@ private static function _sort_by_key($a, $b)
$ap = $a['sort'];
$bp = $b['sort'];
if (is_numeric($ap)) {
if ($ap == $bp) {
return 0;
}
return ($ap > $bp) ? 1 : -1;
return $ap <=> $bp;
}
if (is_string($ap)) {
return strnatcmp($ap, $bp);
@@ -147,7 +147,7 @@ protected function save_attachment_list()
if ($a->metadata->score == $b->metadata->score) {
return strnatcasecmp($a->name, $b->name);
}
return $b->metadata->score - $a->metadata->score;
return $b->metadata->score <=> $a->metadata->score;
});
}

0 comments on commit e040bea

Please sign in to comment.
You can’t perform that action at this time.