Ordering Permutation

Description

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

Usage

1
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.

Details

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

Value

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

Author(s)

Nathan Morris

See Also

order

Examples

1
2
3
x=grnorm(10)
i=gorder(x)
x[i] #sort x

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.