countsort: Low-level sorting: counting sort

Description Usage Arguments Value Examples

View source: R/bitsort.R

Description

In one pass over the vector NAs are handled according to parameter na.last by range_sortna, then, if the vector is unsorted, counting sort is invoked.

Usage

1
countsort(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

Value

a sorted vector

Examples

1
2
3
countsort(c(2L,0L,1L,NA,2L))
countsort(c(2L,0L,1L,NA,2L), na.last=TRUE)
countsort(c(2L,0L,1L,NA,2L), na.last=FALSE)

bit documentation built on Aug. 4, 2020, 9:06 a.m.