--- Cameron Matthews-Dickson <[EMAIL PROTECTED]> wrote:
> I posted what you need to do the qsort method a while back....here it is
> again....this version sorts alphabetically...simple change to make it by
> level....
> 
> int comparedescs(const void *d1, const void *d2)
> {
>     typedef DESCRIPTOR_DATA DD;
>     return strcmp((*(DD **)d1)->character->name, (*(DD
> **)d2)->character->name);
> }
> 
> void do_whotest(CHAR_DATA *ch, char *argument)
> {
>     DESCRIPTOR_DATA *d, *list[50];
>     int x, cnt;
> 
>     for(cnt = 0, d = descriptor_list; d; d = d->next, cnt++)
>     {
>         if(d->character)
>             list[cnt] = d;
>     }
> 
>     send_to_char("Before sort:\n\r", ch);
>     for(x = 0; x < cnt; x++)
>         printf_to_char(ch, "%s\n\r", list[x]->character->name);
> 
>     qsort(list, cnt, sizeof(DESCRIPTOR_DATA *), comparedescs);
> 
>     send_to_char("\n\rAfter sort:\n\r", ch);
>     for(x = 0; x < cnt; x++)
>         printf_to_char(ch, "%s\n\r", list[x]->character->name);
> }
> 

Better hope you don't have more than 50 players on at a time.. You'd be better
off running through the list once and getting a count (or storing the count
somewhere) to make the array sized correctly. Other than that, it looks ok.

~Kender

=====
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GCS/L/C/O d-(+) s++: a-- C+++$>++++ UBLS++++$ 
P+++(--)$ L+++>++++ E--- W+>++$ N !o K? w(--) !O 
M- !V PS+ PE(++) Y+ PGP->+ t+ 5 X+() R(+) tv+@ 
b++(+++) !DI+++ D G(-) e>+++$ h---() r+++ y+++
------END GEEK CODE BLOCK------

__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com

Reply via email to