MCPcopy Create free account
hub / github.com/microsoft/SandDance / compareN

Function compareN

docs/app/js/sanddance-app.js:106779–106789  ·  view source on GitHub ↗
(fields, orders, n)

Source from the content-addressed store, hash-verified

106777 return ascending(field3(a), field3(b)) * order;
106778 };
106779const compareN = (fields, orders, n)=>{
106780 orders.push(0); // pad zero for convenient lookup
106781 return function(a, b) {
106782 let f, c = 0, i = -1;
106783 while(c === 0 && ++i < n){
106784 f = fields[i];
106785 c = ascending(f(a), f(b));
106786 }
106787 return c * orders[i];
106788 };
106789};
106790function constant(_) {
106791 return isFunction(_) ? _ : ()=>_;
106792}

Callers 1

comparatorFunction · 0.70

Calls 2

ascendingFunction · 0.70
fFunction · 0.70

Tested by

no test coverage detected