qsort does not work for double array
问题 I try to sort an array of double value using qsort, but it doesn't seems to work. Wonder what has gone wrong here?? #include <stdio.h> #include <stdlib.h> static double compare (const void * a, const void * b) { if (*(double*)a > *(double*)b) return 1; else if (*(double*)a < *(double*)b) return -1; else return 0; } int main() { int idx; double* sum_least_square_err; sum_least_square_err = (double*) malloc (2500*2500*sizeof(double)); sum_least_square_err[0] = 0.642; sum_least_square_err[1] = 0