Code: void checkAndSwap(int *array, int j, int value) { int done = 0; if (array[j] > value) { array[j + 1] = array[j]; if (--j < 0) { done = 1; } } else { done = 1; } if (done) { array[j + 1] = value; } else { checkAndSwap(array, j, value); } } void insertionSort(int *array, int length) { static int i; int j = i, value; if (++i < length) { value = array[i]; checkAndSwap(array, j, value); insertionSort(array, length); } else { i = 0; } } Example of use: Code: #define LENGTH 8 int array[LENGTH] = { 5, 7, 0, 3, 4, 2, 6, 1 }; insertionSort(array, LENGTH);