Implementation of the counting sort and various other function