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
Comparison sort counting sort is an example algorithm that runs in linear time. Other integer sorting algorithms, such as radix sort, are not asymptotically faster than comparison sorting, but can be faster in practice. The problem of sorting pairs of numbers by their sum is not subject to the bound either (the square resulting from the pairing up); the best known algorithm still takes time, but only comparisons. The number of comparisons that a comparison sort algorithm requires increases in proportion to formula_1, where formula_2 is the number of elements to sort. This bound is asymptotically tight. Given a list of distinct