spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pwend...@apache.org
Subject git commit: SPARK-1322, top in pyspark should sort result in descending order.
Date Wed, 26 Mar 2014 16:16:45 GMT
Repository: spark
Updated Branches:
  refs/heads/master b859853ba -> a0853a39e


SPARK-1322, top in pyspark should sort result in descending order.

Author: Prashant Sharma <prashant.s@imaginea.com>

Closes #235 from ScrapCodes/SPARK-1322/top-rev-sort and squashes the following commits:

f316266 [Prashant Sharma] Minor change in comment.
58e58c6 [Prashant Sharma] SPARK-1322, top in pyspark should sort result in descending order.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/a0853a39
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/a0853a39
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/a0853a39

Branch: refs/heads/master
Commit: a0853a39e1907700737ec924367cd2610da8395a
Parents: b859853
Author: Prashant Sharma <prashant.s@imaginea.com>
Authored: Wed Mar 26 09:16:37 2014 -0700
Committer: Patrick Wendell <pwendell@gmail.com>
Committed: Wed Mar 26 09:16:37 2014 -0700

----------------------------------------------------------------------
 python/pyspark/rdd.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/a0853a39/python/pyspark/rdd.py
----------------------------------------------------------------------
diff --git a/python/pyspark/rdd.py b/python/pyspark/rdd.py
index ca2dc11..019c249 100644
--- a/python/pyspark/rdd.py
+++ b/python/pyspark/rdd.py
@@ -693,11 +693,11 @@ class RDD(object):
         """
         Get the top N elements from a RDD.
 
-        Note: It returns the list sorted in ascending order.
+        Note: It returns the list sorted in descending order.
         >>> sc.parallelize([10, 4, 2, 12, 3]).top(1)
         [12]
         >>> sc.parallelize([2, 3, 4, 5, 6]).cache().top(2)
-        [5, 6]
+        [6, 5]
         """
         def topIterator(iterator):
             q = []
@@ -711,7 +711,7 @@ class RDD(object):
         def merge(a, b):
             return next(topIterator(a + b))
 
-        return sorted(self.mapPartitions(topIterator).reduce(merge))
+        return sorted(self.mapPartitions(topIterator).reduce(merge), reverse=True)
 
     def take(self, num):
         """


Mime
View raw message