diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-08-29 21:44:09 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-08-29 21:44:09 -0700 |
commit | f4eb0c2e7c11c6ec77304dc2c798c15bc2971cfd (patch) | |
tree | 2cdb4c93b7de243f52df7a6479c46595b6437a27 | |
parent | dd9f7f30e879123e57a32492c7c82d9d2b361678 (diff) | |
download | txr-f4eb0c2e7c11c6ec77304dc2c798c15bc2971cfd.tar.gz txr-f4eb0c2e7c11c6ec77304dc2c798c15bc2971cfd.tar.bz2 txr-f4eb0c2e7c11c6ec77304dc2c798c15bc2971cfd.zip |
* lib.c (multi_sort_less): Change the semantics so that when the
list of the functions is empty, the left item is considered less
than the right, thereby preserving the order.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib.c | 10 |
2 files changed, 11 insertions, 5 deletions
@@ -1,5 +1,11 @@ 2012-08-29 Kaz Kylheku <kaz@kylheku.com> + * lib.c (multi_sort_less): Change the semantics so that when the + list of the functions is empty, the left item is considered less + than the right, thereby preserving the order. + +2012-08-29 Kaz Kylheku <kaz@kylheku.com> + * eval.c (mapcarv): Changed to external linkage. * eval.h (mapcarv): Declaration added. @@ -3996,20 +3996,20 @@ val sort(val seq, val lessfun, val keyfun) static val multi_sort_less(val funcs, val llist, val rlist) { - val less = nil; + val less = t; while (funcs) { val func = pop(&funcs); val left = pop(&llist); val right = pop(&rlist); - if (funcall2(func, left, right)) { - less = t; + if (funcall2(func, left, right)) break; - } - if (funcall2(func, right, left)) + if (funcall2(func, right, left)) { + less = nil; break; + } } return less; |