sortBy {SparkR}R Documentation

Sort an RDD by the given key function.

Description

Sort an RDD by the given key function.

Usage

sortBy(rdd, func, ascending, numPartitions)

## S4 method for signature 'RDD,'function',missingOrLogical,missingOrInteger'
sortBy(rdd, func,
  ascending, numPartitions)

Arguments

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.

Value

An RDD where all elements are sorted.

Examples

## 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)

[Package SparkR version 0.1 Index]