ProAnswers.org

algorithm Insertion Sort

algorithm Insertion Sort

void insertion_sort(int list[], int length){

	    int i, j, temp;

	    for(i = 2; i < length; i++)

	        {

	        temp = list[i];

	        for(j = i - 1; j >= 0 && list[j] > temp; j--)

	            list[j + 1] = list[j];

	        j++;

	        list[j] = temp;

	    }

	}