Notice how I demonstrated the use of qsort() in post #4:
Code:
qsort(pointers, size, sizeof(pointers[0]), cmp);
Compare it with your own use of qsort() here:
Code:
qsort(array_amplitudes, length_array_range, sizeof(t_amplitude_index *), (void *)compare_structs);
You are taking the sizeof the wrong thing, and you are casting a function pointer to void when it is unnecessary (and wrong). You should write:
Code:
qsort(array_amplitudes, length_array_range, sizeof(array_amplitudes[0]), compare_structs);
Also, although your compare_structs function does indeed cover all possible cases, it would still be better to write it such that it becomes even more obvious that all control paths will return a value:
Code:
int compare_structs(const void *a, const void *b){
t_amplitude_index *struct_a = (t_amplitude_index *) a;
t_amplitude_index *struct_b = (t_amplitude_index *) b;
if (struct_a->amplitude < struct_b->amplitude) return 1;
else if (struct_a->amplitude == struct_b->amplitude) return 0;
else return -1;
}