Alex,
'with_collate' is one of the functions included in the withr package (
https://cran.rstudio.com/web/packages/withr/).
So you could simply write
sort_c <- function(x) withr::with_collate("C", sort(x))
The usage semantics and implementation are essentially identical to what
Hadley describe
Hi Alex,
As far as I know, that's the best solution. In roxygen, I've wrapped
it up with a couple of helpers:
set_collate <- function(locale) {
cur <- Sys.getlocale(category = "LC_COLLATE")
Sys.setlocale(category = "LC_COLLATE", locale = locale)
cur
}
with_collate <- function(locale, code)