You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
alfgaar
changed the title
the function comparator is flawn and must not be used with array.sort
the function comparator is flaw and must not be used with array.sort
Jul 23, 2015
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.
The text was updated successfully, but these errors were encountered: