title: C++ Sorting Array Recursion
body: <p>I am creating a small program that is supposed to sort integers in an array in ascending order, but I am extremely stuck on the algorithm that I am supposed to use. I cannot iterate through the array, I must instead use a recursion function. I am allowed to have an auxiliary function that can find the smallest index in the array, which I have done successfully, but I am having the hardest time figuring out how to use that function to sort my array in the recursion function. Here is the code that I have so far, I understand that my sortIntegers function is way off.</p>
  
  <pre><code>int main()
  {
      int numbers[] = {8, 2, 5, 1, 3};
      sortingIntegers(numbers, 5);
      return 0;
  }
  
  void sortingIntegers(int *list, int size) {
      if (size == 1) {
          for (int i = 0; i &lt; size; i++) {
              cout &lt;&lt; list[i] &lt;&lt; ", ";
          }
      } else {
          for (int z = 0; z &lt; size; z++) {
              if (list[size - 1] == smallestIndex(list)) {
                  for (int y = 0; y &lt; size; y++) {
                      swap(list[z], list[y]);
                  }
              }
          }
          sortingIntegers(list, size - 1);
      }
  
  }
  
  int smallestIndex(int *array) {
      int smallest = array[0];
      for (int i = 1; i &lt; sizeof(array); i++) {
          if (array[i] &lt; smallest) {
              smallest = array[i];
          }
      }
      return smallest;
  }
  </code></pre>