public static function max($list, callable $iterator = null, $context = null)
    {
        static::associate($iterator, $context);

        !$iterator && $iterator = function ($item) {
            return static::identity($item);
        };

        $max = null;
        $result = null;
        static::each($list, function ($item) use ($iterator, & $max, & $result) {
            $num = $iterator($item);
            if (!isset($max) || $num > $max)
                list($result, $max) = [$item, $num];
        });

        return $result;
    }
public static function max($list, callable $iterator = null, $context = null)
    {
        static::associate($iterator, $context);

        !$iterator && $iterator = function ($item) {
            return static::identity($item);
        };

        $max = null;
        $result = null;
        static::each($list, function ($item) use ($iterator, & $max, & $result) {
            $num = $iterator($item);
            if (!isset($max) || $num > $max)
                list($result, $max) = [$item, $num];
        });

        return $result;
    }
public static function max ( $ list , callable $ iterator = null , $ context = null ) { static :: associate ( $ iterator , $ context ) ; ! $ iterator && $ iterator = function ( $ item ) { return static :: identity ( $ item ) ; } ; $ max = null ; $ result = null ; static :: each ( $ list , function ( $ item ) use ( $ iterator , & $ max , & $ result ) { $ num = $ iterator ( $ item ) ; if ( ! isset ( $ max ) || $ num > $ max ) list ( $ result , $ max ) = [ $ item , $ num ] ; } ) ; return $ result ; }
Returns the maximum value in list. If iterator is passed, it will be used on each value to generate the
criterion by which the value is ranked.

@category Collection Functions

@param traversable $list the list of items
@param callable $iterator optional, the comparision function
@param object $context optional, if provided will become the context of $iterator

@return mixed
Returns the maximum value in list . If iterator is passed it will be used on each value to generate the criterion by which the value is ranked .