Commit 9ed1c18
committed
Fix Java comparator symmetry. #114
Java sort enforces compare symmetry:
sgn(compare(x, y)) == -sgn(compare(y, x))
This is not mandatory for the Jsonata comparator, and produces the error ("violates general contract") if it doesn't.
This change ensures Java compare symmetry. Runtime complexity remains O(2) == O(1).
Fixes original unit tests (2 test overrides removed) and the sorting test data provided.1 parent bf8ec3a commit 9ed1c18
2 files changed
Lines changed: 4 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1959 | 1959 | | |
1960 | 1960 | | |
1961 | 1961 | | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
1962 | 1966 | | |
1963 | 1967 | | |
1964 | 1968 | | |
1965 | 1969 | | |
1966 | 1970 | | |
1967 | 1971 | | |
1968 | 1972 | | |
1969 | | - | |
1970 | | - | |
1971 | 1973 | | |
1972 | 1974 | | |
1973 | 1975 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | 133 | | |
144 | 134 | | |
145 | 135 | | |
| |||
0 commit comments