Property comparators
423485
public static ConditionalCriteria equalProperty(Property<?> propertyLeft, Property<?> propertyRight) {
		return new ConditionalCriteria(Operator.EqualProperty, propertyLeft, propertyRight.getName());
	}
367976
def matches(self, properties):
        
        try:
            # Use the comparator
            return self.comparator(self.value, properties[self.name])
        except KeyError:
            # Criterion key is not in the properties
            return False
828187
public static final <T extends Comparable<T>> int comparator(T val1, T def1, T val2, T def2) {
		return comparator(val1 == null? def1 : val1, val2 == null? def2 : val2);
		// return (val1 == null? def1 : val1).compareTo(val2 == null? def2 : val2);
	}
589092
SortPropertyOrder convert2SortPropertyOrder(final SortOrder order) {
		switch (order) {
		case ASCENDING:
			return SortPropertyOrder.ASCENDING;
		case DESCENDING:
			return SortPropertyOrder.DESCENDING;
		default:
			throw new IllegalArgumentException("Unknown SortOrder: " + order);
		}
	}
865277
function arrayIndexOfComparer(array, item, comparer) {
    for (var i = 0, len = array.length; i < len; i++) {
      if (comparer(array[i], item)) { return i; }
    }
    return -1;
  }
1248300
public static ExpressionComparator compare(Class<?> type, String... properties) {
		return compare(type, asList(properties));
	}
1001289
function variadicComparator(comparator) {
    return variaderize(function(itemsToCompare) {
      var result;

      for (var i = 0; i < itemsToCompare.length - 1; i++) {
        result = comparator(itemsToCompare[i], itemsToCompare[i + 1]);
        if (result === false) return result;
      }

      return result;
    });
  }
1050385
private void initComparators() {
		TupleMRConfigBuilder.initializeComparators(context.getHadoopContext()
		    .getConfiguration(), tupleMRConfig);
		customComparators = new RawComparator<?>[maxDepth + 1];
		for(int i = minDepth; i <= maxDepth; i++) {
			SortElement element = tupleMRConfig.getCommonCriteria().getElements().get(i);
			if(element.getCustomComparator() != null) {
				customComparators[i] = element.getCustomComparator();
			}
		}
	}
768827
def build_comparators(*values_or_types):
    '''
    
    '''
    comparators = []
    for item in values_or_types:
        if isinstance(item, Comparator):
            comparators.append(item)
        elif isinstance(item, type):
            # If you are passing around a type you will have to build a Equals
            # comparator
            comparators.append(Any(IsA(item), Is(item)))
        else:
            comparators.append(Equals(item))
    return comparators
696160
public Comparator<T> thenComparing(final java.util.Comparator<? super T> other) {
            final Comparator<T> me = this;
            return new Comparator<T>() {
                @Override
                public int compare(T o1, T o2) {
                    int ret = (me.compare(o1, o2));
                    return (0 == ret) ? other.compare(o1, o2) : ret;
                }
            };
        }
905240
def _Comparator(self, operator):
    """"""
    if operator == "=":
      return lambda x, y: x == y
    elif operator == ">=":
      return lambda x, y: x >= y
    elif operator == ">":
      return lambda x, y: x > y
    elif operator == "<=":
      return lambda x, y: x <= y
    elif operator == "<":
      return lambda x, y: x < y
    elif operator == "!":
      return lambda x, y: x != y
    raise DefinitionError("Invalid comparison operator %s" % operator)
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);
            }

        };
	}
444951
public static ExpressionComparator compareTo(List<String> properties) {
		ExpressionComparator comparator = ExpressionComparator.create();
		for (String property : properties) {
			comparator.with(thisProperty(property), thatProperty(property), true);
		}
		return comparator;
	}
289794
function multisort(properties) {
    return function multiCompare(a, b) {
      var i = 0;
      var result = 0;
      var numberOfProperties = properties.length;
      while(result === 0 && i < numberOfProperties) {
        result = sort(properties[i])(a, b);
        i++;
      }
      return result;
    };
  }
1158990
function(items) {
            var hasRelativePositioning = hasNumberProperty(items, 'relativePosition');

            for(var i = 0; i < items.length; i++) {
                if(i == items.length - 1)
                    items[i].diffWithNextRelativePos = undefined;
                else
                    items[i].diffWithNextRelativePos = items[i + 1].relativePosition - items[i].relativePosition;
            }
        }
73818
function (locationsarray) {
			this.writeDebug('sortNumerically',arguments);
			var property = (
				this.settings.sortBy !== null &&
				this.settings.sortBy.hasOwnProperty('prop') &&
				typeof this.settings.sortBy.prop !== 'undefined'
			) ?  this.settings.sortBy.prop : 'distance';

			if (this.settings.sortBy !== null && this.settings.sortBy.hasOwnProperty('order') && this.settings.sortBy.order.toString() === 'desc') {
				locationsarray.sort(function (a, b) {
					return ((b[property] < a[property]) ? -1 : ((b[property] > a[property]) ? 1 : 0));
				});
			} else {
				locationsarray.sort(function (a, b) {
					return ((a[property] < b[property]) ? -1 : ((a[property] > b[property]) ? 1 : 0));
				});
			}
		}
1254015
function dateComparators(props, propName) {
    if (!props[propName]) {
      return;
    }
    for (var i = 0; i < props[propName].length; i++) {
      var comparatorIsValid = false;
      for (var j = 0; j < legalComparators.length; j++) {
        if (legalComparators[j] === props[propName][i]) {
          comparatorIsValid = true;
          break;
        }
      }
      if (!comparatorIsValid) {
        return new Error('Date comparator provided is not supported.\n          Use only ' + legalComparators);
      }
    }
  }