//create an ordered skill table
struct ordered_skill_type {
SKILL_DATA *skill;
short int sn;
};
typedef struct ordered_skill_type ORDERED_SKILL_DATA;
ORDERED_SKILL_DATA* ordered_skill_table[MAX_SKILL - 2];
int compare_skill(const void *v1, const void *v2) {
ORDERED_SKILL_DATA *a1 = *(ORDERED_SKILL_DATA**)v1;
ORDERED_SKILL_DATA *a2 = *(ORDERED_SKILL_DATA**)v2;
return strcasecmp(a1->skill->name, a2->skill->name);
}
for (sn = 1;sn < MAX_SKILL -1;sn ++) {//last skill is the NULL one first the reserved…
ordered_skill_table[sn-1] = malloc(sizeof(ORDERED_SKILL_DATA));
ordered_skill_table[sn-1]->skill = (SKILL_DATA*)&skill_table[sn];
ordered_skill_table[sn-1]->sn = sn;
}
qsort(ordered_skill_table, MAX_SKILL-2, sizeof(ordered_skill_table[0]), compare_skill);
I'm wondering if someone can help me. Let me start by saying I'm not the most experienced coder. I want to change the do_wizhelp command to sort alphabetically. I am just not sure how to do it. Right now, our commands feature has everything jumbled together. And I'd like to take what I learn here and apply it to the other commands to sort them also by starting number/letter (such as do_commands, etc…). So, I'm hopeful someone can point me in the right direction and explain it to me in layman's terms too.
Thank you,
Arholly