Counting sort initialization of the output array, each take time. Therefore, the time for the whole algorithm is the sum of the times for these steps, . Because it uses arrays of length and , the total space usage of the algorithm is also . For problem instances in which the maximum key value is significantly smaller than the number of items, counting sort can be highly space-efficient, as the only storage it uses other than its input and output arrays is the Count array which uses space . If each item to be sorted is itself an integer, and used as
Sort (C++) cases), requiring only quasilinear time with exponent 2 – O("n" log "n") – if additional memory is not available, but linearithmic time O("n" log "n") if additional memory is available. This allows the use of in-place merge sort for in-place stable sorting and regular merge sort for stable sorting with additional memory. Partial sorting is implemented by , which takes a range of elements and an integer , and reorders the range so that the smallest elements are in the first positions in sorted order (leaving the remaining in the remaining positions, in some unspecified order). Depending on design this