Replace comparison function with one that honours qsort() requirements.
Signed-off-by: Bård Skaflestad <Bard.Skaflestad@sintef.no>
This commit is contained in:
committed by
Bård Skaflestad
parent
ee9db9493c
commit
de91035e3a
@@ -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);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user