Ensure file encoding is specified for sort_c

This commit is contained in:
Winston Chang
2020-05-11 13:42:10 -05:00
parent aedbfb11af
commit 89dbfcecbf

View File

@@ -213,6 +213,10 @@ sortByName <- function(x) {
# Sort a vector. If a character vector, sort using C locale, which is consistent
# across platforms. Note that radix sort uses C locale according to ?sort.
sort_c <- function(x, ...) {
# Use UTF-8 encoding, because if encoding is "unknown" for non-ASCII
# characters, the sort() will throw an error.
if (is.character(x))
x <- enc2utf8(x)
sort(x, method = "radix", ...)
}