186 void * a_,
size_t count,
size_t size,
187 int (*compare)(
void const *,
void const *),
size_t * idx) {
189 if (count < 2)
return;
197 size_t stack_size = 1;
199 stack[0].r = count-1;
202 void * temp = (
unsigned char*)x + size;
203 unsigned char * a = a_;
211 while ( stack_size > 0 ) {
214 size_t l = stack[stack_size].l;
215 size_t r = stack[stack_size].r;
223 memcpy(x, &a[((l+r+1) / 2)*size], size);
228 while(compare(&a[i*size], x) < 0) i++;
231 while(compare(x, &a[j*size]) < 0) j--;
237 memcpy(temp, &a[i*size], size);
238 memcpy(&a[i*size], &a[j*size], size);
239 memcpy(&a[j*size], temp, size);
242 size_t temp_idx = idx[i];
256 stack[stack_size].l = l;
257 stack[stack_size].r = j;
267 stack[stack_size].l = i;
268 stack[stack_size].r = r;
void yac_qsort_index(void *a_, size_t count, size_t size, int(*compare)(void const *, void const *), size_t *idx)