Reputation: 3113
I have a 3D array: float input[2][50][1000];
I want to quick sort it from:
qsort (x, sizeof(x)/sizeof(*x), sizeof(*x), comp);
where comp is
int comp (const void * elem1, const void * elem2) {
float f = *((float*)elem1);
float s = *((float*)elem2);
if (f > s) return 1;
if (f < s) return -1;
return 0;
}
I just want to sort 1 dimension of my 3D array, i.e I want to sort input[0][temp][0]
, input[0][temp][1]
, input[0][temp][2]
and so on.
Ques: What do I replace x
with?
Forgive me if it sounds stupid
Upvotes: 1
Views: 155
Reputation: 40145
float (*x)[1000] = &input[0][temp];
qsort (x, sizeof(*x)/sizeof(**x), sizeof(**x), comp);
Upvotes: 1