Now, I have seen various examples, but I don\'t get what they mean.
Here\'s my structure
typedef struct profile{
char gender[1];
double soc;
The strict version of a comparator takes two constant void pointers:
int compare(const void *v1, const void *v2)
{
const struct profile *p1 = v1;
const struct profile *p2 = v2;
if (p1->gender > p2->gender)
return(+1);
else if (p1->gender < p2->gender)
return(-1);
else if (p1->soc > p2->soc)
return(+1);
else if (p1->soc < p2->soc)
return(-1);
else
return(0);
}
This compares the gender field first, then the soc field. This is how you handle any multipart comparison.