Takes a predicate-like and returns a comparator (-1,0,1).
338727
function(fun) {
      return function(x, y) {
        if (truthy(fun(x, y)))
          return -1;
        else if (truthy(fun(y, x)))
          return 1;
        else
          return 0;
      };
    }
423505
@Override
    public Predicate lt(Expression<? extends Number> arg0, Number arg1)
    {
        return new ComparisonPredicate(arg0, arg1, ConditionalOperator.LT);
    }
743394
public static <T1 extends Comparable<T1>, T2 extends Comparable<T2>> Comparator<Pair<T1, T2>> naturalOrder() {
        return new Comparator<Pair<T1,T2>>() {

            @Override
            public int compare(Pair<T1, T2> lhs, Pair<T1, T2> rhs) {
                return compareTo(lhs, rhs);
            }

        };
	}
398032
def comparable(self):
    """"""
    sub_comparable_string = (
        'range_offset: 0x{0:08x}, range_size: 0x{1:08x}').format(
            self.range_offset, self.range_size)
    return self._GetComparable(sub_comparable_string=sub_comparable_string)
393836
function find(srcArr, predicate) {
      var idx = indexOf(srcArr, predicate);
      return idx > -1 ? srcArr[idx] : UDF;
    }
672211
private static int compare(long v1, long v2) {
		int pos = 0;
		if (v1 != v2) {
			long x = v1 ^ v2;
			pos += Long.numberOfLeadingZeros(x);
			return pos;
		}
		return -1;
	}
577886
def comparison_filter(term, value)
      value.map do |k, v|
        comparator = k.to_sym.in?([:after, :greater_than, :gt]) ? :gt : :lt
        range_filter(term, v, comparator)
      end
    end
793383
public static Predicate<Number> getGreaterOrEqual(Number target) {
		return number -> number.doubleValue() >= target.doubleValue();
	}
1023109
function _getNumConsecutiveHits (arrayLike, predicate) {
    var idx = 0;
    var len = arrayLike.length;

    while (idx < len && predicate(arrayLike[idx], idx, arrayLike)) {
        idx++;
    }

    return idx;
}
1290435
public static <T extends Comparable<? super T>> Iterator<T> getSortedIterator (Iterable<T> coll)
    {
        return getSortedIterator(coll.iterator(), new Comparator<T>() {
            public int compare (T o1, T o2) {
                if (o1 == o2) { // catches null == null
                    return 0;
                } else if (o1 == null) {
                    return 1;
                } else if (o2 == null) {
                    return -1;
                }
                return o1.compareTo(o2); // null-free
            }
        });
    }
1291214
static int compareLexical(BitStore a, BitStore b) {
		int aSize = a.size();
		int bSize = b.size();
		int diff = a.size() - b.size();
		ListIterator<Integer> as = a.ones().positions(aSize);
		ListIterator<Integer> bs = b.ones().positions(bSize);
		while (true) {
			boolean ap = as.hasPrevious();
			boolean bp = bs.hasPrevious();
			if (ap && bp) {
				int ai = as.previous();
				int bi = bs.previous() + diff;
				if (ai == bi) continue;
				return ai > bi ? 1 : -1;
			} else {
				return bp ? -1 : 1;
			}
		}

	}
198900
public static <T extends Comparable<T>> Predicate<T> between(
      final T low, final T high) {
    return new Predicate<T>() {
      @Override
      public boolean apply(T obj) {
        return obj != null
            && (low == null || obj.compareTo(low) >= 0)
            && (high == null || obj.compareTo(high) < 0);
      }
    };
  }
276965
def comparator(operator):
    
    @wraps(operator)
    def wrapper(self, other):
        if not isinstance(other, (VersionInfo, dict)):
            return NotImplemented
        return operator(self, other)
    return wrapper
737832
function compSort(p1, p2) {
    if (p1[0] > p2[0]) {
      return -1;
    } else if (p1[0] < p2[0]) {
      return 1;
    } else if (p1[1] > p2[1]) {
      return -1;
    } else if (p1[1] < p2[1]) {
      return 1;
    } else {
      return 0;
    }
  }
125882
@Override
    public Predicate ge(Expression<? extends Number> arg0, Number arg1)
    {
        // TODO Auto-generated method stub
        return new ComparisonPredicate(arg0, arg1, ConditionalOperator.GTE);
    }
830588
public static final <T extends Comparable<T>> int comparator(T val1, T val2) {
		if(val1 == null) {
			return val2 == null? 0 : -1;
		} else {
			return val2 == null? 1 : val1.compareTo(val2);
		}
	}
147400
def comparator(self, value):
        """"""
        if not isinstance(value, RangeCheckComparatorType):
            raise AttributeError("%s comparator is invalid in RangeCheck." % (value,))
        self._comparator = value