6. A simplest known sorting method called “counting sort” is described as follows.
Declare an array count and set count[k] to the number of key values that are less
than k. Therefore, the record with key k can be placed in position count[k] of an
output list. (You should beware of the possibility of equal key values. See an
example in Figure 1.) Assume that all keys of the records are integers and their
values are in range of [0, d], where d is a constant. Write an algorithm to sort a set
of records with size n by the key value using this method (including how to
determine the count[k]). (15%)