compare function for dates
- by Chris
I have struct as:
struct stored
{
char *dates; // 12/May/2010, 10/Jun/2010 etc..
int ctr;
};
// const
struct stored structs[] = {{"12/May/2010", 1}, {"12/May/2011", 1},
{"21/May/2009", 4}, {"12/May/2011", 3},
{"10/May/2011", 8}, {"12/May/2011", 4 }};
What I want to do is to sort struct 'stored' by stored.dates.
qsort(structs, 9, sizeof(struct stored*), sortdates); // sortdates function
I'm not quite sure what would be a good way to sort those days? Compare them as c-strings?