sym_sort: Symmetrical sort

sym_sortR Documentation

Symmetrical sort

Description

Sort a vector symmetrically, i.e., the two most extreme values are put at opposite ends and repeated until the median value(s) is(are) put in the middle of the sorted vector.

Usage

sym_sort(x, rev = FALSE, index.return = FALSE)

Arguments

x

a numeric, complex, character, or logical vector

rev

logical; if TRUE, vectors are sorted in reverse

index.return

logical; if TRUE, the ordering index vector is returned

See Also

kinda_sort

Examples

sym_sort(letters)
sym_sort(letters, rev = TRUE)

x <- runif(50)
plot(sym_sort(x))
plot(x[sym_sort(x, index.return = TRUE)])

plot(sym_sort(x, rev = TRUE))
plot(-sym_sort(-x, rev = TRUE))


raredd/rawr documentation built on Feb. 25, 2025, 1:48 p.m.