In one pass over the vector NAs are handled according to parameter
na.last by range_sortna(), then, if the vector is unsorted,
threeway quicksort is invoked.
quicksort3(x, na.last = NA)
Arguments
- x
an integer vector
- na.last
NA removes NAs, FALSE puts NAs at the beginning,
TRUE puts NAs at the end
Examples
countsort(c(2L, 0L, 1L, NA, 2L))
#> [1] 0 1 2 2
countsort(c(2L, 0L, 1L, NA, 2L), na.last=TRUE)
#> [1] 0 1 2 2 NA
countsort(c(2L, 0L, 1L, NA, 2L), na.last=FALSE)
#> [1] NA 0 1 2 2