diff options
author | Robert de Bath <rdebath@poboxes.com> | 1998-07-01 01:00:00 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:40:31 +0200 |
commit | ec5f28e3f1400b5dacb88eda2d9db472a20b4349 (patch) | |
tree | b3215b2306709d0412fd7845c78ca63ccaa2e29b /libc/misc/qsort.c | |
parent | 2f828530e36a02c5b4c534e42ab812370c2bf7d9 (diff) | |
download | dev86-ec5f28e3f1400b5dacb88eda2d9db472a20b4349.tar.gz |
Import Dev86src-0.14.3.tar.gzv0.14.3
Diffstat (limited to 'libc/misc/qsort.c')
-rw-r--r-- | libc/misc/qsort.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libc/misc/qsort.c b/libc/misc/qsort.c index cee53c3..a4a98b7 100644 --- a/libc/misc/qsort.c +++ b/libc/misc/qsort.c @@ -7,6 +7,12 @@ * dal@syntel.UUCP United States of America * "It's not reality that's important, but how you perceive things." */ + +/* + * Sun Feb 8 21:02:15 EST 1998 claudio@pos.inf.ufpr.br (Claudio Matsuoka) + * Changed sort direction + */ + #include <string.h> char *_qbuf = 0; /* pointer to storage for qsort() */ @@ -35,10 +41,10 @@ register int (*cmp) (); base[i] = *p; while (i < j) { - while (((*cmp) ((base + j), p)) > 0) + while (((*cmp) ((base + j), p)) <= 0) --j; base[i] = base[j]; - while ((i < j) && (((*cmp) ((base + i), p)) <= 0)) + while ((i < j) && (((*cmp) ((base + i), p)) > 0)) ++i; base[j] = base[i]; } @@ -77,10 +83,10 @@ register int (*cmp) (); base[i] = *p; while (i < j) { - while (((*cmp) ((base + j), p)) > 0) + while (((*cmp) ((base + j), p)) <= 0) --j; base[i] = base[j]; - while ((i < j) && (((*cmp) ((base + i), p)) <= 0)) + while ((i < j) && (((*cmp) ((base + i), p)) > 0)) ++i; base[j] = base[i]; } @@ -120,10 +126,10 @@ register int (*cmp) (); p = _qbuf; while (i < j) { - while (((*cmp) ((base + size * j), p)) > 0) + while (((*cmp) ((base + size * j), p)) <= 0) --j; moveitem((base + size * i), (base + size * j), size); - while ((i < j) && (((*cmp) ((base + size * i), p)) <= 0)) + while ((i < j) && (((*cmp) ((base + size * i), p)) > 0)) ++i; moveitem((base + size * j), (base + size * i), size); } |