How to override opCmp when two different sorts are needed?

C. Dunn cdunn2001 at gmail.com
Tue Aug 14 17:24:37 PDT 2007


Jarrett Billingsley Wrote:
> Write your own sort routine which takes a given predicate.  :\
> 
> Tango provides such a routine in tango.core.Array; phobos provides no such 
> analogue.  With phobos, either write your own routine, or use 
> std.c.stdlib.qsort.  I'll let you decide which is more elegant. 

It's not just a matter of elegance.  C++ std::sort() is way, way faster than qsort in cstdlib because the comparison function gets inlined.  Sorting is one place where inlining is critical.



More information about the Digitalmars-d mailing list