4 * This is actually combsort. It's an O(n log n) algorithm with
5 * simplicity/small code size being its main virtue.
12 static inline size_t newgap(size_t gap
)
14 gap
= (gap
* 10) / 13;
15 if (gap
== 9 || gap
== 10)
23 void qsort(void *base
, size_t nmemb
, size_t size
,
24 int (*compar
) (const void *, const void *))
38 for (i
= 0, p1
= base
; i
< nmemb
- gap
; i
++, p1
+= size
) {
40 if (compar(p1
, p2
= (char *)base
+ j
* size
) > 0) {
41 memswap(p1
, p2
, size
);
45 } while (gap
> 1 || swapped
);