spark get key inside reduce code example Example: pyspark reduce a list RDD.takeOrdered(5, key = lambda x: x[0])