src/Bag.php
private function iterateeToComparator(callable $iteratee, $ascending = true)
    {
        return function ($a, $b) use ($iteratee, $ascending) {
            // PHP 7.0
            // return $iteratee($a) <=> $iteratee($b);

            $a = $iteratee($a);
            $b = $iteratee($b);

            if ($a === $b) {
                return 0;
            }

            if ($ascending) {
                return $a > $b ? 1 : -1;
            }

            return $a > $b ? -1 : 1;
        };
    }
private function iterateeToComparator(callable $iteratee, $ascending = true)
    {
        return function ($a, $b) use ($iteratee, $ascending) {
            // PHP 7.0
            // return $iteratee($a) <=> $iteratee($b);

            $a = $iteratee($a);
            $b = $iteratee($b);

            if ($a === $b) {
                return 0;
            }

            if ($ascending) {
                return $a > $b ? 1 : -1;
            }

            return $a > $b ? -1 : 1;
        };
    }
private function iterateeToComparator ( callable $ iteratee , $ ascending = true ) { return function ( $ a , $ b ) use ( $ iteratee , $ ascending ) { // PHP 7.0 // return $iteratee($a) <=> $iteratee($b); $ a = $ iteratee ( $ a ) ; $ b = $ iteratee ( $ b ) ; if ( $ a === $ b ) { return 0 ; } if ( $ ascending ) { return $ a > $ b ? 1 : - 1 ; } return $ a > $ b ? - 1 : 1 ; } ; }
Returns a comparison function that calls the `$iteratee` function
for both values being compared before comparing them.

@param callable $iteratee
@param bool     $ascending

@return \Closure
Returns a comparison function that calls the $iteratee function for both values being compared before comparing them .