Learn R Programming

gmatrix (version 0.3)

gorder: Ordering Permutation

Description

gorder returns a permutation which rearranges its first argument into ascending or descending order.

Usage

gorder(x, decreasing = FALSE, stable = TRUE, sortx=FALSE)

Arguments

x
object to be ordered
decreasing
logical to specify sort order
stable
make sure that ties are in the original order
sortx
if sortx=TRUE, then x will be modified by sorting it. This avoids an extra duplication of the x. By leaving sortx=FALSE, an extra duplication of x is performed to avoid changing the input value.

Value

a gvector of type "integer" which will permute the input vector to the proper sort order.

Details

Unlike the base R function, only one input column may be given. The thrust library is used for this operation.

See Also

order

Examples

Run this code
x=grnorm(10)
i=gorder(x)
x[i] #sort x

Run the code above in your browser using DataLab