Replace comparison function with one that honours qsort() requirements.

Signed-off-by: Bård Skaflestad <Bard.Skaflestad@sintef.no>
This commit is contained in:
Bård Skaflestad
2012-06-08 11:40:43 +00:00
committed by Bård Skaflestad
parent ee9db9493c
commit de91035e3a

View File

@@ -53,8 +53,13 @@
Compare function passed to qsortx */
static int compare(const void *a, const void *b)
{
if (*(double*)a < *(double*) b) return -1;
else return 1;
const double a0 = *(const double*) a;
const double b0 = *(const double*) b;
/* { -1, a < b
* compare(a,b) = { 0, a = b
* { 1, a > b */
return (a0 > b0) - (a0 < b0);
}
/*-----------------------------------------------------------------