Great Taste! Less Fillin!
But anyway.
int sort_cmd_table(const void *v1, const void *v2)
{
int cmd1 = *(int *) v1;
int cmd2 = *(int *) v2;
int i = 0;
for (i = 0; cmd_table[idx1].name[i] != '\0'; i++)
{
if (cmd_table[cmd1].name[i] == cmd_table[cmd2].name[i]) continue;
if (cmd_table[cmd2].name[i] == '\0') return 1;
if (cmd_table[cmd1].name[i] > cmd_table[cmd2].name[i]) return 1;
if (cmd_table[cmd1].name[i] < cmd_table[cmd2].name[i]) return -1;
}
return 0;
}
To use:
int index[MIL*4]; make it sizable.
after your command count or wizhelp command count.
qsort(index, count, sizeof(int), sort_cmd_table);
this goes under the 2nd for statement:
cmd = index[i];
everything else should be stock, or for those of us who like to see levels
with our commands it works also.