Counting sort implementation