rthsort: Parallel Sort

Description Usage Arguments Details Value References Examples

View source: R/rthsort.R

Description

Sorts a numeric vector into ascending or descending order.

Usage

1
rthsort(x, decreasing = FALSE, inplace = FALSE, nthreads = rth.nthreads())

Arguments

x

a numeric vector

decreasing

logical; determines if the sort is ascending (decreasing=FALSE) or descending (decreasing=TRUE).

inplace

If TRUE, x is sorted in-place, no new R vectory created.

nthreads

An optional argument for specifying the number of threads (in the case of OpenMP or TBB backends) that the routine should (at most) use. Does nothing with a CUDA backend. See nthreads.

Details

The implementation uses thrust::sort, which does not necessarily preserve the order of tied values.

Value

If decreasing=FALSE, then the input vector is returned in ascending order. Otherwise, the input vector is returned in descending order.

If inplace is TRUE, there is no return value.

References

http://thrust.github.io/doc/group__sorting.html

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
x <- runif(10)
x
rthsort(x)  # outputs sorted x
x  # but x itself is unchanged
rthsort(x,inplace=TRUE)  # outputs nothing
x  # but x is now a sorted version of itself

## End(Not run)

matloff/Rth documentation built on May 21, 2019, 12:55 p.m.