sortByKey {SparkR}R Documentation

Sort a (k, v) pair RDD by k.

Description

Sort a (k, v) pair RDD by k.

Usage

sortByKey(rdd, ascending, numPartitions)

## S4 method for signature 'RDD,missingOrLogical,missingOrInteger'
sortByKey(rdd, ascending,
  numPartitions)

Arguments

rdd

A (k, v) pair RDD to be sorted.

ascending

A flag to indicate whether the sorting is ascending or descending.

numPartitions

Number of partitions to create.

Value

An RDD where all (k, v) pair elements are sorted.

Examples

## Not run: 
##D sc <- sparkR.init()
##D rdd <- parallelize(sc, list(list(3, 1), list(2, 2), list(1, 3)))
##D collect(sortByKey(rdd)) # list (list(1, 3), list(2, 2), list(3, 1))
## End(Not run)

[Package SparkR version 0.1 Index]