to the function sort: -1 means LT, 1 means GT and 0 means EQ. To the comparator function: -1 means the first test to pass, 1 means the opposite of first test, and 0 means both tests failure. Comparator drifts away from what really matters ordinal position.
if the first test has predicate lessThan and x is less than y, ok
but if the first test has the pedicate greaterThan and x is greater than y, comparator returns -1 meaning GT, and sorts only accepts -1 to mean LT.
Besides comparator only accepts 2 parameters predicates, isPrime, isOdd, isEven are one parameter predicates. Don't say they can be passed to comparator, they do not fit comparator contract.
to the function sort: -1 means LT, 1 means GT and 0 means EQ. To the comparator function: -1 means the first test to pass, 1 means the opposite of first test, and 0 means both tests failure. Comparator drifts away from what really matters ordinal position. if the first test has predicate lessThan and x is less than y, ok but if the first test has the pedicate greaterThan and x is greater than y, comparator returns -1 meaning GT, and sorts only accepts -1 to mean LT.
Besides comparator only accepts 2 parameters predicates, isPrime, isOdd, isEven are one parameter predicates. Don't say they can be passed to comparator, they do not fit comparator contract.