*comparison in C
Hi all,
I'm trying to write a bottom-up sort function, it has the same interface as qsort() in stdlib.h like that one
void qsort(type *base,int nel,int width,int (*compar)(type *,type *))
and I have read my data into an array of structs that have two members a char * and an int . My comparison functions work fie when I use qsort(), but because I have to write my own sort function(which has same interface as above), I can't seem to pass the correct arguments to the comparison function inside my sorting function, my comparison function has this interface
int intcompare( const void *i, const void *j)
int comparestr( const void *i, const void *j)
So in my sorting function I don't call either, rather I call compar, because my comparisons depend on whether the user wants to sort by int's or alphabetically. So I want to be able to pass to the comparison function aux[i] and aux[j] which are of type NODE which is my struct.
If you've read this far I appreciate your help. Thanks in advance
|