It's not that hard to think up of. You just need to make sure the recursion is "iterating" the array at every element (not in any particular language, but you should get it):
Code:
ssort(array, start_pos, inc_pos, swap_pos) {
if(inc_pos >= array.length) {
u = array[swap_pos];
array[swap_pos] = array[start_pos];
array[start_pos] = u;
if(start_pos != array.length - 1) {
return ssort(array, start_pos+1, start_pos+1, start_pos+1);
}
return array;
}
if(array[inc_pos] < array[swap_pos]) {
return ssort(array, start_pos, inc_pos+1, inc_pos);
} else {
return ssort(array, start_pos, inc_pos+1, swap_pos);
}
}
sorted_array = ssort(array, 0, 0, 0)
Though I am not sure if this is the most efficient way. This is the fully recursive method I thought up of, but I think others tend to just use a combination of recursion and iteration (i.e. a for loop within the recursive function). Hope this helps.