Functions::extractExpression. * Comparator returns an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. * * @param mixed ... * @return callable */ public static function compareBy() { $expressions = func_get_args(); $comparators = Arrays::map($expressions, function ($expression) { return new EvaluatingComparator(Functions::extractExpression($expression)); }); return sizeof($comparators) == 1 ? $comparators[0] : new CompoundComparator($comparators); } /** * Returns comparator according to which order between element is reversed. * * @param $comparator * @return callable */ public static function reverse($comparator) { return new ReversedComparator($comparator); } /** * Returns a comparator that uses default comparison operators. * * @return callable */ public static function natural() { return function ($a, $b) { if ($a == $b) { return 0; } return ($a < $b) ? -1 : 1; }; } }