SORT VALUES, NULL IS THE LEAST VALUE
    :param left: LHS
    :param right: RHS
    :param ordering: (-1, 0, 1) TO AFFECT SORT ORDER
    :return: The return value is negative if x < y, zero if x == y and strictly positive if x > y.
481656
def value_compare(left, right, ordering=1):
    

    try:
        ltype = left.__class__
        rtype = right.__class__

        if ltype in list_types or rtype in list_types:
            if left == None:
                return ordering
            elif right == None:
                return - ordering

            left = listwrap(left)
            right = listwrap(right)
            for a, b in zip(left, right):
                c = value_compare(a, b) * ordering
                if c != 0:
                    return c

            if len(left) < len(right):
                return - ordering
            elif len(left) > len(right):
                return ordering
            else:
                return 0

        if ltype is float and isnan(left):
            left = None
            ltype = none_type
        if rtype is float and isnan(right):
            right = None
            rtype = none_type

        null_order = ordering*10
        ltype_num = TYPE_ORDER.get(ltype, null_order)
        rtype_num = TYPE_ORDER.get(rtype, null_order)

        type_diff = ltype_num - rtype_num
        if type_diff != 0:
            return ordering if type_diff > 0 else -ordering

        if ltype_num == null_order:
            return 0
        elif ltype is builtin_tuple:
            for a, b in zip(left, right):
                c = value_compare(a, b)
                if c != 0:
                    return c * ordering
            return 0
        elif ltype in data_types:
            for k in sorted(set(left.keys()) | set(right.keys())):
                c = value_compare(left.get(k), right.get(k)) * ordering
                if c != 0:
                    return c
            return 0
        elif left > right:
            return ordering
        elif left < right:
            return -ordering
        else:
            return 0
    except Exception as e:
        Log.error("Can not compare values {{left}} to {{right}}", left=left, right=right, cause=e)
1326865
function _sort(a,b) {
    if (a.weight < b.weight) {
      return 1;
    }
    else if (a.weight > b.weight) {
      return -1;
    }
    else {
      return 0;
    }
  }
635262
public static int compareFlags(int left, int right) {
		if (left == right) {
			return 0;
		}
		int leftSuccess = left & SUCCESS_OR_LAMBDA;
		int rightSuccess = right & SUCCESS_OR_LAMBDA;
		if (leftSuccess != rightSuccess) {
			if (leftSuccess == 0)
				return 1;
			if (rightSuccess == 0)
				return -1;
			if (leftSuccess < rightSuccess)
				return -1;
			return 1;
		}
		if ((left & SYNONYM) != (right & SYNONYM)) {
			if ((left & SYNONYM) != 0)
				return 1;
			return -1;
		}
		return 0;
	}
1240485
public static boolean adOrOver(Bound<?> left, Bound<?> right) {
        boolean isValueEqual = left.getValue().equals(right.getValue());
        boolean isBothOpen = left.getBoundaryType() == RangeBoundary.OPEN && right.getBoundaryType() == RangeBoundary.OPEN;
        return isValueEqual && !isBothOpen;
    }
82483
function (left, right) {
    var result = [];
    var leftIndex = 0;
    var rightIndex = 0;

    while (leftIndex < left.length && rightIndex < right.length) {
        if (dependencyComparator(left[leftIndex], right[rightIndex]) < 1) {
            result.push(left[leftIndex++]);
        } else {
            result.push(right[rightIndex++]);
        }
    }

    return result.
    concat(left.slice(leftIndex)).
    concat(right.slice(rightIndex));
}
472403
def evaluate(self, values):
        
        return self.left.evaluate(values) or self.right.evaluate(values)
700615
function defaultComparison(left, right) {
        var leftS = $toString(left),
            rightS = $toString(right),
            val = 1;

        if (leftS === rightS) {
            val = +0;
        } else if (leftS < rightS) {
            val = -1;
        }

        return val;
    }
802613
function compare([l, ...left], [r, ...right]) {
  if (l < r) {
    return -1;
  }
  if (l > r) {
    return 1;
  }

  if (left.length === 0) {
    return 0;
  }

  return compare(left, right);
}
61946
@SuppressWarnings({ "rawtypes", "unchecked" })
    public static int compareTo(final Comparable thisValue, final Comparable otherValue, final OrderDirection orderDirection, final OrderDirection nullOrderDirection) {
        if (null == thisValue && null == otherValue) {
            return 0;
        }
        if (null == thisValue) {
            return orderDirection == nullOrderDirection ? -1 : 1;
        }
        if (null == otherValue) {
            return orderDirection == nullOrderDirection ? 1 : -1;
        }
        return OrderDirection.ASC == orderDirection ? thisValue.compareTo(otherValue) : -thisValue.compareTo(otherValue);
    }
804848
public static StringExpression left(Expression<String> lhs, int rhs) {
        return left(lhs, ConstantImpl.create(rhs));
    }
1157055
private int order(String value1, String value2) {
        int result = -1;

        if (value1 == value2) {
            result = 0;
        } else if (value1 != null) {
            if (value2 != null) {
                result = value1.compareTo(value2);
            } else {
                result = 1;
            }
        } else {
            result = -1;
        }

        return result;
    }
1215009
public static Number minus(Number left, Number right) {
        return NumberMath.subtract(left, right);
    }
293639
function(loc, left, right) {
			var a, b;
			if (loc instanceof Range) {
				a = loc.start;
				b = loc.end;
			} else {
				a = b = loc;
			}
			
			return cmp(this.start, a, left || '<=') && cmp(this.end, b, right || '>');
		}
795483
public static Boolean lt(Object left, Object right) {
        return EvalHelper.compare(left, right, null, (l, r) -> l.compareTo(r) < 0);
    }
949191
def normalize_sort(sort=None):
    

    if not sort:
        return Null

    output = FlatList()
    for s in listwrap(sort):
        if is_text(s) or mo_math.is_integer(s):
            output.append({"value": s, "sort": 1})
        elif not s.field and not s.value and s.sort==None:
            #ASSUME {name: sort} FORM
            for n, v in s.items():
                output.append({"value": n, "sort": sort_direction[v]})
        else:
            output.append({"value": coalesce(s.field, s.value), "sort": coalesce(sort_direction[s.sort], 1)})
    return wrap(output)
778430
def get_comparable_values_for_ordering(self):
        

        return (0 if self.position >= 0 else 1, int(self.position), str(self.name), str(self.description))
40058
private Boolean compareValues(Session session, Object left, Object right) {
        if (left == null) {
            if (opType == OpTypes.NOT_DISTINCT) {
                return right == null;
            }
            return null;
        }

        if (right == null) {
            return (opType == OpTypes.NOT_DISTINCT) ? Boolean.FALSE : null;
        }

        int result = nodes[LEFT].dataType.compare(left, right);

        switch (opType) {

            case OpTypes.EQUAL :
            case OpTypes.NOT_DISTINCT :
                return result == 0 ? Boolean.TRUE
                                   : Boolean.FALSE;

            case OpTypes.NOT_EQUAL :
                return result != 0 ? Boolean.TRUE
                                   : Boolean.FALSE;

            case OpTypes.GREATER :
                return result > 0 ? Boolean.TRUE
                                  : Boolean.FALSE;

            case OpTypes.GREATER_EQUAL :
                return result >= 0 ? Boolean.TRUE
                                   : Boolean.FALSE;

            case OpTypes.SMALLER_EQUAL :
                return result <= 0 ? Boolean.TRUE
                                   : Boolean.FALSE;

            case OpTypes.SMALLER :
                return result < 0 ? Boolean.TRUE
                                  : Boolean.FALSE;

            default :
                throw Error.runtimeError(ErrorCode.U_S0500, "Expression");
        }
    }