sorting/ins_sort.c
/**
 * perform an in-place insertion sort of an array struct. 
 */
perform an in-place insertion sort of an array struct.
perform an in - place insertion sort of an array struct .
int int_array_insertion_sort(int_array_t *array) {
    int i, j, key;
    for(j = 0; j < array->length; j++){   
        key = array->data[j];
        i = j - 1;
        while(i >= 0 && array->data[i] > key){
            array->data[i + 1] = array->data[i];
            i = i - 1;
        }
        array->data[i + 1] = key;
    }
    return 0;
}
int int_array_insertion_sort ( int_array_t * array ) { int i , j , key ; for ( j = 0 ; j < array -> length ; j ++ ) { key = array -> data [ j ] ; i = j - 1 ; while ( i >= 0 && array -> data [ i ] > key ) { array -> data [ i + 1 ] = array -> data [ i ] ; i = i - 1 ; } array -> data [ i + 1 ] = key ; } return 0 ; }
perform an in-place insertion sort of an array struct.
perform an in - place insertion sort of an array struct .
/*printf("\nentering the function");*/ /*printf("\nloop: %d",j);*/ /*printf("\nleaving the function");*/