Skip to content

Commit f65ffd9

Browse files
committed
FIX: SORT/COMPARE is using reversed order when using integer as a result from the function
fixes: metaeducation/rebol-issues#2376
1 parent 18e2d34 commit f65ffd9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/core/t-block.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,12 @@ static struct {
415415
return -1;
416416
}
417417
if (IS_INTEGER(val)) {
418-
if (VAL_INT64(val) > 0) return 1;
418+
if (VAL_INT64(val) < 0) return 1;
419419
if (VAL_INT64(val) == 0) return 0;
420420
return -1;
421421
}
422422
if (IS_DECIMAL(val)) {
423-
if (VAL_DECIMAL(val) > 0) return 1;
423+
if (VAL_DECIMAL(val) < 0) return 1;
424424
if (VAL_DECIMAL(val) == 0) return 0;
425425
return -1;
426426
}

src/tests/units/series-test.r3

+2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ Rebol [
117117
--test-- "SORT/compare"
118118
;@@ https://github.com/rebol/rebol-issues/issues/720
119119
--assert [3 2 1] = sort/compare [1 2 3] func [a b] [a > b]
120+
;@@ https://github.com/rebol/rebol-issues/issues/2376
121+
--assert [1 3 10] = sort/compare [1 10 3] func[x y][case [x > y [1] x < y [-1] true [0]]]
120122

121123
--test-- "SORT/skip/compare"
122124
;@@ https://github.com/rebol/rebol-issues/issues/1152

0 commit comments

Comments
 (0)