MCPcopy
hub / github.com/microsoft/SandDance / stableCompare

Function stableCompare

docs/tests/v2/es6/js/sanddance.js:76633–76635  ·  view source on GitHub ↗

* Generate an augmented comparator function that provides stable * sorting by tuple id when the given comparator produces ties. * @param {function} cmp - The comparator to augment. * @param {function} [f] - Optional tuple accessor function. * @return {function} An augmented comparator function.

(cmp, f)

Source from the content-addressed store, hash-verified

76631
76632
76633function stableCompare(cmp, f) {
76634 return !cmp ? null : f ? (a, b) => cmp(a, b) || tupleid(f(a)) - tupleid(f(b)) : (a, b) => cmp(a, b) || tupleid(a) - tupleid(b);
76635}
76636},{}],"m0dW":[function(require,module,exports) {
76637"use strict";
76638

Callers

nothing calls this directly

Calls 2

tupleidFunction · 0.70
fFunction · 0.70

Tested by

no test coverage detected