Counting Sort in Python


  • A is the input array.
  • B is the output array.
  • C is the temporary array. C gives the frequency numbers of each value in A. C_m gives the cumulative numbers of each value; which means that there are five numbers whose values are less than or equal to five.
  • In order to get output arrays in B, output each value from input A sequence followed by decreasing its count by 1.