qsort compare functions
    Gyepi SAM 
    gyepi at praxis-sw.com
       
    Fri Nov 22 07:23:24 CET 2002
    
    
  
On Fri, Nov 22, 2002 at 12:17:11AM -0500, David Relson wrote:
> Qsort simply wants to know how to order two items.  Bogofilter wants them 
> in probability order (primarily) and  alphabetic order 
> (secondarily).  Given this info, I assert that the proper code is:
> 
>     const discrim_t *d1 = id1;
>     const discrim_t *d2 = id2;
> 
>     if (d1->prob > d2->prob) return 1;
>     if (d1->prob < d2->prob) return -1;
>     return strcmp(d1->key, d2->key);
> 
> If there are no objections, I shall make this correction.
I was going to object (it's my nature),
but my attempts to disprove your assertion
convinced me of its correctness. So I support your correction,
assuming your assumptions are true.
-Gyepi
    
    
More information about the bogofilter-dev
mailing list