# Recursive Array Sort

This is a discussion on Recursive Array Sort within the C++ Programming forums, part of the General Programming Boards category; How would I accomplish this? You don't need to help me code it unless you want to be generous, but ...

1. ## Recursive Array Sort

How would I accomplish this? You don't need to help me code it unless you want to be generous, but I just would like to know the psuedocode because I am quite confused:

Write a recursive function to sort an array of integers into ascending order using the following idea: Place the smallest element in the first position, then sort the rest of the array by a recursive call. This is ar ecursive version of the selection sort. Note that merely doing a selection sort will not suffice here, since the function to do the sorting must itself be recursive and not merely use a recusive function.

2. psuedocode::::

Code:
```void swap(int array[], int index1, int index2){
int temp = array[index1];
array[index1] = array[index2];
array[index2] = temp;

}

void sort(const int array[],int startpoint, int arraylength) {

if(startpoint == arraylength - 1) return;

int minindex = startpoint;

//find smallest in rest of array
for(int i = startpoint ; i < arraylength ; i++) if(array[i] < array[minindex]) minindex = i;

//put smallest in first spot
swap(array, startpoint, minindex);

sort(array,startpoint+1,arraylength);

}```