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.





An arbitrary R object for which a names function returns a character vector.


The same object as obj, but sorted with .objects first.


Eliot McIntire


items <- c(A = "a", Z = "z", `.D` = ".d", `_C` = "_C")
#>    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")
#>       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"