 | Algorithm C (Comparison counting).
This algorithm sorts R1, ···, RN on the keys
K1, ···, KN by maintaining an auxiliary table
COUNT[1], ···, COUNT[N ]
to count the number of keys less than a given key. After
the conclusion of the algorithm, COUNT[j] + 1
will specify the final position of record Rj.
 | [Clear COUNTs.] Set COUNT[1]
through COUNT[N ] to zero.
|
 | [Loop on i.] Perform step C3, for
i = N, N-1, ···, 2;
then terminate the algorithm.
|
 | [Loop on j.] Perform step C4, for
j = i-1, i-2, ···, 1.
|
 | [Compare Ki : Kj.] If Ki < Kj,
increase COUNT[j] by 1; otherwise
increase COUNT[i] by 1.
|
|