sort(x, partial = NULL, na.last = NA)
The treatment of missing values is controlled by the na.last argument. The default allows the output to have fewer elements than the input. Any attributes (except names) of x will be lost in the sorting; the result is always a vector.
Infinite values are allowed and are sorted appropriately. Character data are sorted according to the collating sequence, where digits precede upper-case letters, which precede lower-case letters; the position of other characters is unintuitive. Complex data are sorted according to the real part, and the imaginary part is used to break ties.
Sorting of non-atomic data is not allowed, because the definition of ordering is too vague.
mydata <- c(2, 9, 18, NA, 3, 2) # create sample objectsort(mydata) # missing values are deleted
sort(mydata, na.last = T) # put missing values at the end
sort(mydata, na.last = "") # cause an error if mydata has missing values