Learn R Programming

bit (version 4.5.0.1)

countsort: Low-level sorting: counting sort

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

countsort(x, na.last = NA)

Value

a sorted vector

Arguments

x

an integer vector

na.last

NA removes NAs, FALSE puts NAs at the beginning, TRUE puts NAs at the end

Examples

Run this code
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)

Run the code above in your browser using DataLab