nodes: 0, module; 1, function_definition; 2, function_name:_radixPass; 3, parameters; 4, block; 5, identifier:a; 6, identifier:b; 7, identifier:r; 8, identifier:n; 9, identifier:K; 10, expression_statement; 11, expression_statement; 12, comment:# counter array; 13, for_statement; 14, expression_statement; 15, for_statement; 16, for_statement; 17, comment:"""
      Stable sort of the sequence a according to the keys given in r.
  
      >>> a=range(5)
      >>> b=[0]*5
      >>> r=[2,1,3,0,4]
  
      >>> _radixPass(a, b, r, 5, 5)
      >>> b
      [3, 1, 0, 2, 4]
  
      When n is less than the length of a, the end of b must be left unaltered.
      >>> b=[5]*5
      >>> _radixPass(a, b, r, 2, 2)
      >>> b
      [1, 0, 5, 5, 5]
  
      >>> _a=a=[1, 0]
      >>> b= [0]*2
      >>> r=[0, 1]
      >>> _radixPass(a, b, r, 2, 2)
      >>> a=_a
      >>> b
      [0, 1]
  
      >>> a=[1, 1]
      >>> _radixPass(a, b, r, 2, 2)
      >>> b
      [1, 1]
  
      >>> a=[0, 1, 1, 0]
      >>> b= [0]*4
      >>> r=[0, 1]
      >>> _radixPass(a, b, r, 4, 2)
      >>> a=_a
      >>> b
      [0, 0, 1, 1]
      """; 18, assignment; 19, identifier:i; 20, call; 21, comment:# count occurrences; 22, block; 23, assignment; 24, identifier:i; 25, call; 26, comment:# exclusive prefix sums; 27, block; 28, identifier:a_i; 29, subscript; 30, comment:# sort; 31, block; 32, identifier:c; 33, call; 34, identifier:range; 35, argument_list; 36, expression_statement; 37, identifier:sum; 38, integer:0; 39, identifier:range; 40, argument_list; 41, expression_statement; 42, expression_statement; 43, expression_statement; 44, identifier:a; 45, slice; 46, expression_statement; 47, expression_statement; 48, identifier:_array; 49, argument_list; 50, identifier:n; 51, augmented_assignment; 52, binary_operator:K + 1; 53, assignment; 54, assignment; 55, augmented_assignment; 56, identifier:n; 57, assignment; 58, augmented_assignment; 59, string:"i"; 60, binary_operator:[0] * (K + 1); 61, subscript; 62, integer:1; 63, identifier:K; 64, integer:1; 65, identifier:t; 66, subscript; 67, subscript; 68, identifier:sum; 69, identifier:sum; 70, identifier:t; 71, subscript; 72, identifier:a_i; 73, subscript; 74, integer:1; 75, list; 76, parenthesized_expression; 77, identifier:c; 78, subscript; 79, identifier:c; 80, identifier:i; 81, identifier:c; 82, identifier:i; 83, identifier:b; 84, subscript; 85, identifier:c; 86, subscript; 87, integer:0; 88, binary_operator:K + 1; 89, identifier:r; 90, subscript; 91, identifier:c; 92, subscript; 93, identifier:r; 94, identifier:a_i; 95, identifier:K; 96, integer:1; 97, identifier:a; 98, identifier:i; 99, identifier:r; 100, identifier:a_i
code: def _radixPass(a, b, r, n, K):
      """
      Stable sort of the sequence a according to the keys given in r.
  
      >>> a=range(5)
      >>> b=[0]*5
      >>> r=[2,1,3,0,4]
  
      >>> _radixPass(a, b, r, 5, 5)
      >>> b
      [3, 1, 0, 2, 4]
  
      When n is less than the length of a, the end of b must be left unaltered.
      >>> b=[5]*5
      >>> _radixPass(a, b, r, 2, 2)
      >>> b
      [1, 0, 5, 5, 5]
  
      >>> _a=a=[1, 0]
      >>> b= [0]*2
      >>> r=[0, 1]
      >>> _radixPass(a, b, r, 2, 2)
      >>> a=_a
      >>> b
      [0, 1]
  
      >>> a=[1, 1]
      >>> _radixPass(a, b, r, 2, 2)
      >>> b
      [1, 1]
  
      >>> a=[0, 1, 1, 0]
      >>> b= [0]*4
      >>> r=[0, 1]
      >>> _radixPass(a, b, r, 4, 2)
      >>> a=_a
      >>> b
      [0, 0, 1, 1]
      """
      c = _array("i", [0] * (K + 1))  # counter array
  
      for i in range(n):  # count occurrences
          c[r[a[i]]] += 1
  
      sum = 0
  
      for i in range(K + 1):  # exclusive prefix sums
          t = c[i]
          c[i] = sum
          sum += t
  
      for a_i in a[:n]:  # sort
          b[c[r[a_i]]] = a_i
          c[r[a_i]] += 1