Fast high-level methods for sorting and ordering. These are wrappers to
ramsort.integer64() and friends and do not modify their arguments.
# S3 method for class 'integer64'
sort(
x,
decreasing = FALSE,
has.na = TRUE,
na.last = TRUE,
stable = TRUE,
optimize = c("time", "memory"),
VERBOSE = FALSE,
...
)
# S3 method for class 'integer64'
order(
...,
na.last = TRUE,
decreasing = FALSE,
has.na = TRUE,
stable = TRUE,
optimize = c("time", "memory"),
VERBOSE = FALSE
)a vector to be sorted by ramsort.integer64() and
ramsortorder.integer64(), i.e. the output of sort.integer64()
boolean scalar telling ramsort whether to sort increasing or decreasing
boolean scalar defining whether the input vector might
contain NAs. If we know we don't have NAs, this may speed-up. Note
that you risk a crash if there are unexpected NAs with has.na=FALSE
boolean scalar telling ramsort whether to sort NAs last
or first. Note that 'boolean' means that there is no third option
NA as in sort()
boolean scalar defining whether stable sorting is needed. Allowing non-stable may speed-up.
by default ramsort optimizes for 'time' which requires more RAM, set to 'memory' to minimize RAM requirements and sacrifice speed
cat some info about chosen method
further arguments, passed from generics, ignored in methods
sort returns the sorted vector and vector returns the order positions.
x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE))
x
#> integer64
#> [1] <NA> <NA> 5 2 <NA> 7 7 <NA> <NA> 2 5 <NA> 7 <NA> <NA>
#> [16] <NA> <NA> 2 <NA> <NA> <NA> <NA> 3 <NA> <NA> 3 3 3 <NA> 4
#> [31] <NA> <NA>
sort(x)
#> integer64
#> [1] 2 2 2 3 3 3 3 4 5 5 7 7 7 <NA> <NA>
#> [16] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
#> [31] <NA> <NA>
message("the following has default optimize='time' which is faster but requires more RAM
, this calls 'ramorder'")
#> the following has default optimize='time' which is faster but requires more RAM
#> , this calls 'ramorder'
order.integer64(x)
#> [1] 4 10 18 23 26 27 28 30 3 11 6 7 13 1 2 5 8 9 12 14 15 16 17 19 20
#> [26] 21 22 24 25 29 31 32
message("slower with less RAM, this calls 'ramsortorder'")
#> slower with less RAM, this calls 'ramsortorder'
order.integer64(x, optimize="memory")
#> [1] 4 10 18 23 26 27 28 30 3 11 6 7 13 1 2 5 8 9 12 14 15 16 17 19 20
#> [26] 21 22 24 25 29 31 32