sortBy {SparkR} | R Documentation |
Sort an RDD by the given key function.
sortBy(rdd, func, ascending, numPartitions) ## S4 method for signature 'RDD,'function',missingOrLogical,missingOrInteger' sortBy(rdd, func, ascending, numPartitions)
rdd |
An RDD to be sorted. |
func |
A function used to compute the sort key for each element. |
ascending |
A flag to indicate whether the sorting is ascending or descending. |
numPartitions |
Number of partitions to create. |
An RDD where all elements are sorted.
## Not run:
##D sc <- sparkR.init()
##D rdd <- parallelize(sc, list(3, 2, 1))
##D collect(sortBy(rdd, function(x) { x })) # list (1, 2, 3)
## End(Not run)