Retrieves a lexicographical comparator for the given type.

@param elemComp
the comparator to use for comparing the elements.

@return a comparator for comparing objects of type <code>T</code> based on lexicographical ordering.
507371
public static <T extends Iterable<U>, U> Comparator<T> lexComparator(Comparator<U> elemComp) {
        return new LexComparator<>(elemComp);
    }
1146868
@Override
    public int compareTo(MimeType other) {
        int comp = getType().compareToIgnoreCase(other.getType());
        if (comp != 0) {
            return comp;
        }
        comp = getSubtype().compareToIgnoreCase(other.getSubtype());
        if (comp != 0) {
            return comp;
        }
        comp = getParameters().size() - other.getParameters().size();
        if (comp != 0) {
            return comp;
        }
        TreeSet<String> thisAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
        thisAttributes.addAll(getParameters().keySet());
        TreeSet<String> otherAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
        otherAttributes.addAll(other.getParameters().keySet());
        Iterator<String> thisAttributesIterator = thisAttributes.iterator();
        Iterator<String> otherAttributesIterator = otherAttributes.iterator();
        while (thisAttributesIterator.hasNext()) {
            String thisAttribute = thisAttributesIterator.next();
            String otherAttribute = otherAttributesIterator.next();
            comp = thisAttribute.compareToIgnoreCase(otherAttribute);
            if (comp != 0) {
                return comp;
            }
            String thisValue = getParameters().get(thisAttribute);
            String otherValue = other.getParameters().get(otherAttribute);
            if (otherValue == null) {
                otherValue = "";
            }
            comp = thisValue.compareTo(otherValue);
            if (comp != 0) {
                return comp;
            }
        }
        return 0;
    }
834073
public static <T> List<T> maxList (Iterable<T> iterable, Comparator<? super T> comp)
    {
        Iterator<T> itr = iterable.iterator();
        T max = itr.next();
        List<T> maxes = new ArrayList<T>();
        maxes.add(max);
        if (itr.hasNext()) {
            do {
                T elem = itr.next();
                int cmp = comp.compare(max, elem);
                if (cmp <= 0) {
                    if (cmp < 0) {
                        max = elem;
                        maxes.clear();
                    }
                    maxes.add(elem);
                }
            } while (itr.hasNext());

        } else if (0 != comp.compare(max, max)) {
            // The main point of this test is to compare the sole element to something,
            // in case it turns out to be incompatible with the Comparator for some reason.
            // In that case, we don't even get to this IAE, we've probably already bombed out
            // with an NPE or CCE. For example, the Comparable version could be called with
            // a sole element of null. (Collections.max() gets this wrong.)
            throw new IllegalArgumentException();
        }
        return maxes;
    }
401000
public static <T> ItemsSketch<T> getInstance(final Comparator<? super T> comparator) {
    return getInstance(PreambleUtil.DEFAULT_K, comparator);
  }
763488
static Comparer<byte[]> getBestComparer() {
    try {
      Class<?> theClass = Class.forName(UNSAFE_COMPARER_NAME);

      // yes, UnsafeComparer does implement Comparer<byte[]>
      @SuppressWarnings("unchecked")
      Comparer<byte[]> comparer = (Comparer<byte[]>) theClass
          .getEnumConstants()[0];
      return comparer;
    } catch (Throwable t) { // ensure we really catch *everything*
      LOG.error("Loading lexicographicalComparerJavaImpl...");
      return lexicographicalComparerJavaImpl();
    }
  }
1087361
public static <T extends Comparable<T>> int checkCompare(T a, T b) {
        return a == null ?
                b == null ? 0 : -1 :
                    b == null ? 1 : a.compareTo(b);
      }
763805
function getCompsByType(type, element) {
    var comps = this.getComps(element),
        targetComps = [];
    for (var i = 0; i < comps.length; i++) {
        var comp = comps[i];
        if (comp && comp.type == type) targetComps.push(comp);
    }
    return targetComps;
}
415285
protected Comparator<RequestMapperBean> newComparator()
	{
		return new Comparator<RequestMapperBean>()
		{
			@Override
			public int compare(final RequestMapperBean o1, final RequestMapperBean o2)
			{
				return o1.getCompatibilityScore() - o2.getCompatibilityScore();
			}
		};
	}
658546
public static <T, L extends List<T>> L sortThis(L list, Comparator<? super T> comparator)
    {
        if (list instanceof MutableList)
        {
            ((MutableList<T>) list).sortThis(comparator);
        }
        else if (list instanceof ArrayList)
        {
            ArrayListIterate.sortThis((ArrayList<T>) list, comparator);
        }
        else
        {
            if (list.size() > 1)
            {
                Collections.sort(list, comparator);
            }
        }
        return list;
    }
515028
public static Comparator<MonetaryAmount> sortNumberDesc(){
	        return new Comparator<MonetaryAmount>() {
	            @Override
	            public int compare(MonetaryAmount o1, MonetaryAmount o2) {
	                return sortNumber().compare(o1, o2) * -1;
	            }
	        };
	    }
616923
public static Comparator<CmsAliasTableRow> getComparator() {

        return new Comparator<CmsAliasTableRow>() {

            public int compare(CmsAliasTableRow o1, CmsAliasTableRow o2) {

                String err1 = getValueInternal(o1);
                String err2 = getValueInternal(o2);
                if ((err1 == null) && (err2 == null)) {
                    return 0;
                }
                if (err1 == null) {
                    return -1;
                }
                if (err2 == null) {
                    return 1;
                }
                return 0;
            }
        };
    }
671191
@NotNull
    public ComparatorCompat<T> thenComparing(@NotNull final Comparator<? super T> other) {
        return new ComparatorCompat<T>(thenComparing(comparator, other));
    }
1106385
public static List<? extends Element> getEnclosedElementsDeclarationOrder(TypeElement type) {
        List<? extends Element> result = null;
        try {
            Object binding = field(type, "_binding");

            Class<?> sourceTypeBinding = null;
            {
                Class<?> c = binding.getClass();
                do {
                    if (c.getCanonicalName().equals(
                            "org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding")) {
                        sourceTypeBinding = c;
                        break;
                    }
                } while ((c = c.getSuperclass()) != null);
            }

            final List<Object> declarationOrder;
            if (sourceTypeBinding != null) {
                declarationOrder = findSourceOrder(binding);

                List<Element> enclosedElements = new ArrayList<Element>(type.getEnclosedElements());
                Collections.sort(enclosedElements, new Comparator<Element>() {

                    public int compare(Element o1, Element o2) {
                        try {
                            Object o1Binding = field(o1, "_binding");
                            Object o2Binding = field(o2, "_binding");

                            int i1 = declarationOrder.indexOf(o1Binding);
                            int i2 = declarationOrder.indexOf(o2Binding);

                            return i1 - i2;
                        } catch (Exception e) {
                            return 0;
                        }
                    }

                });
                result = enclosedElements;
            }
        } catch (Exception e) {
            // ignore
        }
        return (result != null) ? result : type.getEnclosedElements();
    }
458929
function getResolvedJsxType(node, elemType, elemClassType) {
            if (!elemType) {
                elemType = checkExpression(node.tagName);
            }
            if (elemType.flags & 524288 /* Union */) {
                var types = elemType.types;
                return getUnionType(types.map(function (type) {
                    return getResolvedJsxType(node, type, elemClassType);
                }), /*subtypeReduction*/ true);
            }
            // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type
            if (elemType.flags & 2 /* String */) {
                return anyType;
            }
            else if (elemType.flags & 32 /* StringLiteral */) {
                // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type
                var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements);
                if (intrinsicElementsType !== unknownType) {
                    var stringLiteralTypeName = elemType.text;
                    var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName);
                    if (intrinsicProp) {
                        return getTypeOfSymbol(intrinsicProp);
                    }
                    var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */);
                    if (indexSignatureType) {
                        return indexSignatureType;
                    }
                    error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements);
                }
                // If we need to report an error, we already done so here. So just return any to prevent any more error downstream
                return anyType;
            }
            // Get the element instance type (the result of newing or invoking this tag)
            var elemInstanceType = getJsxElementInstanceType(node, elemType);
            if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) {
                // Is this is a stateless function component? See if its single signature's return type is
                // assignable to the JSX Element Type
                if (jsxElementType) {
                    var callSignatures = elemType && getSignaturesOfType(elemType, 0 /* Call */);
                    var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0];
                    var callReturnType = callSignature && getReturnTypeOfSignature(callSignature);
                    var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0]));
                    if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) {
                        // Intersect in JSX.IntrinsicAttributes if it exists
                        var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes);
                        if (intrinsicAttributes !== unknownType) {
                            paramType = intersectTypes(intrinsicAttributes, paramType);
                        }
                        return paramType;
                    }
                }
            }
            // Issue an error if this return type isn't assignable to JSX.ElementClass
            if (elemClassType) {
                checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements);
            }
            if (isTypeAny(elemInstanceType)) {
                return elemInstanceType;
            }
            var propsName = getJsxElementPropertiesName();
            if (propsName === undefined) {
                // There is no type ElementAttributesProperty, return 'any'
                return anyType;
            }
            else if (propsName === "") {
                // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead
                return elemInstanceType;
            }
            else {
                var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName);
                if (!attributesType) {
                    // There is no property named 'props' on this instance type
                    return emptyObjectType;
                }
                else if (isTypeAny(attributesType) || (attributesType === unknownType)) {
                    // Props is of type 'any' or unknown
                    return attributesType;
                }
                else if (attributesType.flags & 524288 /* Union */) {
                    // Props cannot be a union type
                    error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType));
                    return anyType;
                }
                else {
                    // Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
                    var apparentAttributesType = attributesType;
                    var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes);
                    if (intrinsicClassAttribs !== unknownType) {
                        var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
                        if (typeParams) {
                            if (typeParams.length === 1) {
                                apparentAttributesType = intersectTypes(createTypeReference(intrinsicClassAttribs, [elemInstanceType]), apparentAttributesType);
                            }
                        }
                        else {
                            apparentAttributesType = intersectTypes(attributesType, intrinsicClassAttribs);
                        }
                    }
                    var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes);
                    if (intrinsicAttribs !== unknownType) {
                        apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
                    }
                    return apparentAttributesType;
                }
            }
        }
1003083
public Comparator<S> comparator() {
        if (mChunkMatcher == null) {
            return mChunkSorter;
        }
        return new Comparator<S>() {
            public int compare(S a, S b) {
                int result = mChunkMatcher.compare(a, b);
                if (result == 0) {
                    result = mChunkSorter.compare(a, b);
                }
                return result;
            }
        };
    }
209777
public static <T extends Comparable<? super T>> int compare(T c1, T c2) {
		return CompareUtil.compare(c1, c2);
	}
544594
public static Comparator<Level> comparator() {
        return new Comparator<Level>() {
            @Override
            public int compare(Level l1, Level l2) {
                return Integer.compare(l1.intValue(), l2.intValue());
            }
        };
    }