spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject git commit: SPARK-1322, top in pyspark should sort result in descending order.
Date Wed, 26 Mar 2014 20:20:05 GMT
Repository: spark
Updated Branches:
  refs/heads/branch-0.9 1f785d46e -> 2f90dc534


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/2f90dc53
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/2f90dc53
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/2f90dc53

Branch: refs/heads/branch-0.9
Commit: 2f90dc5348a64833dd921fd4bde163f291afe18e
Parents: 1f785d4
Author: Prashant Sharma <prashant.s@imaginea.com>
Authored: Wed Mar 26 09:16:37 2014 -0700
Committer: Tathagata Das <tathagata.das1565@gmail.com>
Committed: Wed Mar 26 11:15:02 2014 -0700

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


http://git-wip-us.apache.org/repos/asf/spark/blob/2f90dc53/python/pyspark/rdd.py
----------------------------------------------------------------------
diff --git a/python/pyspark/rdd.py b/python/pyspark/rdd.py
index 6d05ff2..deaf896 100644
--- a/python/pyspark/rdd.py
+++ b/python/pyspark/rdd.py
@@ -627,11 +627,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 = []
@@ -645,7 +645,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