6 * Angband sorting algorithm -- quick sort in place
8 * Note that the details of the data we are sorting is hidden,
9 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
10 * function hooks to interact with the data, which is given as
11 * two pointers, and which may have any user-defined form.
13 void ang_sort_aux(vptr u, vptr v, int p, int q)
31 while (!(*ang_sort_comp)(u, v, b, z)) b--;
34 while (!(*ang_sort_comp)(u, v, z, a)) a++;
40 (*ang_sort_swap)(u, v, a, b);
46 /* Recurse left side */
47 ang_sort_aux(u, v, p, b);
49 /* Recurse right side */
50 ang_sort_aux(u, v, b + 1, q);
55 * Angband sorting algorithm -- quick sort in place
57 * Note that the details of the data we are sorting is hidden,
58 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
59 * function hooks to interact with the data, which is given as
60 * two pointers, and which may have any user-defined form.
62 void ang_sort(vptr u, vptr v, int n)
65 ang_sort_aux(u, v, 0, n - 1);