Counting Sort implementation in C++. Counting Sort is an sorting algorithm which uses knowledge of the range of a set of integers to sort them in linear time ( O(n) ).