title: Python how to address the max value requirement for benchmarking countsort
body: <p>I have been trying to benchmark some different sorts and have gotten most of the problems out but count sort is proving awkward.  Where do I give it a max value? </p>
  
  <p>I have tried a few different methods but this </p>
  
  <p>def counting_sort(arr, maxval):</p>
  
  <pre><code>n = len(arr)
  m = maxval + 1
  count = [0] * m               
  for a in arr:
      count[a] += 1             
  i = 0
  for a in range(m):           
      for c in range(count[a]): # - emit 'count[a]' copies of 'a'
          arr[i] = a
          i += 1
  return arr
  </code></pre>
  
  <p>Gave the error TypeError: counting_sort() missing 1 required positional argument: 'maxval'</p>
  
  <p>So I thought I would try a method that didnt call a max value at the start</p>
  
  <pre><code>    arr = []
      for i in range(0, n, 1):
          arr.append(randint(0, 100))
      return arr
  
  def counting_sort(arr):
      size = len(arr)
      output = [0] * size
  
      # Initialize count array
      count = [0] * 10
  
      # Store the count of each elements in count array
      for i in range(0, size):
          count[arr[i]] += 1
  
      # Store the cummulative count
      for i in range(1, 10):
          count[i] += count[i - 1]
  
      # Find the index of each element of the original array in count array
      # place the elements in output array
      i = size - 1
      while i &gt;= 0:
          output[count[arr[i]] - 1] = arr[i]
          count[arr[i]] -= 1
          i -= 1
  
      # Copy the sorted elements into original array
      for i in range(0, size):
          arr[i] = output[i]
  
      return arr
  
  num_runs = 10
  elements = [100, 250, 500, 750, 1000, 1250, 2500, 3750, 5000]
  def countrunTime():    
  
      stimes = []    
      for i in elements:
          arr = random_array(i)
          countresults = []
          for r in range(num_runs):
  
              start_time = time.time()
  
              counting_sort(arr)
  
              end_time = time.time()
  
              time_elapsed = end_time - start_time
              countresults.append(time_elapsed)
          s = round(mean(countresults),3)
          stimes.append(s)
      return stimes
  
  Returns the error in counting_sort
      count[arr[i]] += 1
  IndexError: list index out of range
  </code></pre>