R/cache-helpers.R
sortDotsUnderscoreFirst.Rd
Internal use only. This exists so Windows, Linux, and Mac machines can have the same order after a sort. It will put dots and underscores first (with the sort key based on their second character, see examples. It also sorts lower case before upper case.
.sortDotsUnderscoreFirst(obj)
.orderDotsUnderscoreFirst(obj)
An arbitrary R object for which a names
function
returns a character vector.
The same object as obj
, but sorted with .objects first.
items <- c(A = "a", Z = "z", `.D` = ".d", `_C` = "_C")
.sortDotsUnderscoreFirst(items)
#> A Z _C .D
#> "a" "z" "_C" ".d"
# dots & underscore (using 2nd character), then all lower then all upper
items <- c(B = "Upper", b = "lower", A = "a", `.D` = ".d", `_C` = "_C")
.sortDotsUnderscoreFirst(items)
#> A B _C .D b
#> "a" "Upper" "_C" ".d" "lower"
# with a vector
.sortDotsUnderscoreFirst(c(".C", "_B", "A")) # _B is first
#> [1] "A" "_B" ".C"