/*
Standard compare function to apply to either branch or task.
773467
function(x, y) {
  var xName = getName(x);
  var yName = getName(y);

  if (typeof xName !== 'string' || xName.length < 1) {
    assert(false);
  }
  if (typeof yName !== 'string' || yName.length < 1) {
    assert(false);
  }

  if (xName === yName) {
    return 0;
  } else if (xName < yName) {
    return -1;
  } else if (xName > yName) {
    return 1;
  } else {
    assert(false);
  }
}
1363358
public static final <T> int compare(T o1, T o2, Comparator<T> comp)
    {
        if (comp != null)
        {
            return comp.compare(o1, o2);
        }
        else
        {
            return ((Comparable<T>)o1).compareTo(o2);
        }
    }
1359738
function compareComponents(a, b) {
  const [aNormalized, bNormalized] = normalizeVersions(a, b);

  for (let i = 0; i < bNormalized.length; i++) {
    const result = compareNumeric(aNormalized[i], bNormalized[i]);
    if (result) {
      return result;
    }
  }

  return 0;
}
701886
def compare(self, path, prefixed_path, source_storage):
        
        # First try a method on the command named compare_<comparison_method>
        # If that doesn't exist, create a comparitor that calls methods on the
        # storage with the name <comparison_method>, passing them the name.
        comparitor = getattr(self, 'compare_%s' % self.comparison_method, None)
        if not comparitor:
            comparitor = self._create_comparitor(self.comparison_method)
        return comparitor(path, prefixed_path, source_storage)
1241742
private int compareToErrStackLines(List<StackLine> stackLines, List<StackLine> errStackLines) {
        if (errStackLines == null || errStackLines.size() == 0) {
            return -1; // already executed
        }
        if (stackLines.size() == 0) {
            throw new IllegalArgumentException("empty stackLine");
        }

        for (int i = 0; i < stackLines.size(); i++) {
            if (i >= errStackLines.size()) {
                throw new IllegalArgumentException(String.format(
                        "stack mismatch:%n[stackLines]%n%s[errStackLines]%n%s",
                        stackLinesStr(stackLines), stackLinesStr(errStackLines)));
            }
            int indexFromTail = stackLines.size() - 1 - i;
            int errIndexFromTail = errStackLines.size() - 1 - i;
            int line = stackLines.get(indexFromTail).getCodeBodyIndex();
            int errLine = errStackLines.get(errIndexFromTail).getCodeBodyIndex();
            if (line < errLine) {
                return -1; // already executed
            } else if (line > errLine) {
                return 1; // not executed
            }
        }
        return 0;
    }
1356976
@Override
	int compare(Treap treap, int node) {
		int vertex = treap.getElement(node);
		return compareVertex_(treap, node, vertex);
	}
1086585
function(a, b, aParent, bParent, prop, compares, options){
		var subsetCompare = function(a, b, aParent, bParent, prop){
			var compare = compares[prop] === undefined ? compares['*'] : compares[prop];

			if (! loop(a, b, aParent, bParent, prop, compare, options ) ) {
				var subsetCheck;
				if( !(prop in aParent)) {
					subsetCheck = "subsetB";
				}
				if( !(prop in bParent) ) {
					subsetCheck = "subsetA";
				}
				if(subsetCheck) {
					if( !options.subset ) {
						options.subset = subsetCheck;
					}
					return options.subset === subsetCheck ? undefined: false;
				}

				return false;
			}
		};

		var aType = typeof a;
		if(aType === 'object' || aType === 'function') {
			return h.eachInUnique(a, subsetCompare, b, subsetCompare, true);
		}
	}
248788
function compare (options, less, x, y) {
  const ifLess = options.asc ? -1 : 1;

  return less(x, y) ? ifLess
    : less(y, x) ? -ifLess
    : 0;
}
907392
function compare(aOther) {
      var thisSeconds = this.toSeconds();
      var otherSeconds = aOther.toSeconds();
      return (thisSeconds > otherSeconds) - (thisSeconds < otherSeconds);
    }
1234288
function compare(specValue, comparisonValue, currentDescription) {

    var lengthIndex = currentDescription.length - 1,
        suite = currentDescription.slice(0, (lengthIndex)).join(" "),
        spec = currentDescription[lengthIndex],
        object = {};

    if (suite === "") {
        object[spec] = specValue;
    } else {
        object[suite] = {};
        object[suite][spec] = specValue;
    }

    if (typeof(specValue) !== 'undefined' && typeof(comparisonValue) !== 'undefined') {
        if (comparisonValue === "PASSED") {
            response.passed.push(object);
        } else {
            response.failed.push(object);
        }
    } else {
        if (config.hint) {
            console.log(("ShouldIt? is running in " + config.hint + " hint mode.\n").green);
            console.log("One of your features has not been implelented.");
            console.log((object[suite][spec] + '\n').grey);
            console.log("The recommended test for you to implement is below:\n");
            console.log(templates(config.hint, suite, spec).yellow);
            console.log("\n");
            throw "end";
        }
        response.pending.push(object);
    }

}
1307517
def visit_Compare(self, node):
        """"""

        if len(node.ops) > 1:
            func = Name(id=self._prefix + 'napi_compare', ctx=Load())
            args = [node.left,
                    List(elts=[Str(op.__class__.__name__)
                               for op in node.ops], ctx=Load()),
                    List(elts=node.comparators, ctx=Load())]
            node = Call(func=func, args=args, keywords=self._kwargs)
            fml(node)
        self.generic_visit(node)
        return node
1216211
function getCompare(_, ctx) {
  var k = 'c:' + _.$compare + '_' + _.$order,
      c = array(_.$compare).map(function(_) {
        return (_ && _.$tupleid) ? tupleid : _;
      });
  return ctx.fn[k] || (ctx.fn[k] = compare(c, _.$order));
}
140377
function compare(buf1, buf2){
    if (buf1.length !== buf2.length)
        return buf1.length - buf2.length;

    for (var i = 0; i < buf1.length; i++)
        if (buf1[i] !== buf2[i])
            return buf1[i] - buf2[i];

    return 0;
}
1341607
function _comparer (a, b) {
    var result = 0;

    if (typeof a !== typeof b) {
        a = String(a);
        b = String(b);
    }

    if (!areSVZ(a, b)) {
        // eslint-disable-next-line no-self-compare
        result = a > b || a !== a ? 1 : -1;
    }

    return result;
}
339897
public static <T> int compare(IntStream s1, IntStream s2, IntBinaryOperator comp)
    {
        PrimitiveIterator.OfInt os1 = s1.iterator();
        PrimitiveIterator.OfInt os2 = s2.iterator();
        while (os1.hasNext() && os2.hasNext())
        {
            int n1 = os1.next();
            int n2 = os2.next();
            int c;
            if (comp == null)
            {
                c = n1 - n2;
            }
            else
            {
                c = comp.applyAsInt(n1, n2);
            }
            if (c != 0)
            {
                return c;
            }
        }
        boolean hn1 = os1.hasNext();
        boolean hn2 = os2.hasNext();
        if (hn1 == hn2)
        {
            return 0;
        }
        if (hn1)
        {
            return 1;
        }
        else
        {
            return -1;
        }
    }
108650
function defaultComparer(a, b) {
    if (typeof a === typeof b
        && (typeof a === "number" || typeof a === "string")) {
        return compareNumberOrString(a, b);
    }
    else if (isComparable(a) && isComparable(b)) {
        return b.compareTo(a);
    }
    throw new Error(`cannot compare ${typeof a} with ${typeof b}`);
}
15466
function defaultComparator(a, b) {
    if (a == b) {
        return 0;
    } else if (a > b) {
        return 1;
    } else if (a < b) {
        return -1;
    } else {
        throw new Error("Unstable comparison: " + a + " compared to " + b);
    }
}