3 * Placed into Public Domain
4 * written by Walter Bright
7 * This is a public domain version of qsort.d.
8 * All it does is call C's qsort(), but runs a little slower since
9 * it needs to synchronize a global variable.
13 * Modified by Sean Kelly for use with the D Runtime Project
20 private import core.stdc.stdlib;
28 private TypeInfo tiglobal;
30 extern (C) int cmp(void* p1, void* p2)
32 return tiglobal.compare(p1, p2);
35 extern (C) long _adSort(Array a, TypeInfo ti)
40 qsort(a.ptr, a.length, cast(size_t)ti.tsize(), &cmp);
42 return *cast(long*)(&a);
49 debug(qsort) printf("array.sort.unittest()\n");
51 int a[] = new int[10];
66 for (int i = 0; i < a.length - 1; i++)
68 //printf("i = %d", i);
69 //printf(" %d %d\n", a[i], a[i + 1]);
70 assert(a[i] <= a[i + 1]);