void sort_vector ()
{
int i, j;
for ( i = 0; i < _num_vrsVector; ++i )
{
for ( j = i+1; j < _num_vrsVector; ++j )
{
if ( _vrsVector[i]->_phase > _vrsVector[j]->_phase ) {
swap_vector ( &_vrsVector[i], &_vrsVector[j] );
}
}
}
}
void swap_vector (struct vrsVector **p, struct vrsVector **q )
{
struct vrsVector *temp;
temp = *p;
*p = *q;
*q = temp;
}
My question is which method is better to do sorting for an array of pointers to structs object in C.
The above code is doing comparison and then do swaping.Another way i know is to use "QSORT".I would like to know that which methods that I just mentioned is better for doing sorting for an array of pointers to objects?
qsortfromstdlib.h