apache/spark — pull request #2094 by davies (2014-08-22 04:58:25+00:00)
Title: [SPARK-2871] [PySpark] add `comp` argument for RDD.max() and RDD.min()

RDD.max(comp=None)

Find the maximum item in this RDD.

@param comp: A function used to compare two elements, the builtin `cmp`
will be used by default.

>>> rdd = sc.parallelize([1.0, 5.0, 43.0, 10.0])
>>> rdd.max()
43.0
>>> rdd.max(lambda a, b: cmp(str(a), str(b)))
5.0

RDD.min(comp=None)

Find the minimum item in this RDD.

@param comp: A function used to compare two elements, the builtin `cmp`
will be used by default.

>>> rdd = sc.parallelize([2.0, 5.0, 43.0, 10.0])
>>> rdd.min()
2.0
>>> rdd.min(lambda a, b: cmp(str(a), str(b)))
10.0