The doubles represented times in nanoseconds, and the program failed to sort properly when the total runtime was larger than (IIRC) 2 seconds. I wonder if you can work out why.
Your fix requires a lot of mental CPU cycles on the part of whoever reads the code. Are you sure it wouldn't have been better to do it the simple, obvious way?
double a = *(double *) dpa;
double b = *(double *) dpb;
if (a > b) return 1;
if (b < a) return -1;
return 0;
(Spoiler alert) the fix was: https://github.com/libguestfs/libguestfs/commit/1f4a0bd90df3...