Return methods from typeElement ordered by comparator
@param typeElement
@param comparator
@return
764325
protected List<ExecutableElement> getOrderedMethods(TypeElement typeElement, Comparator<ExecutableElement> comparator) {
		List<ExecutableElement> methods = ElementFilter.methodsIn(typeElement.getEnclosedElements());
		Collections.sort(methods, comparator);
		return methods;
	}
447114
public static Sort toSort(ComparatorItem comparatorItem) {
    List<Sort.Order> orderList = new LinkedList<>();
    ComparatorItem item = comparatorItem;
    Sort.Order order;
    while ((order = toSortOrder(item)) != null) {
      orderList.add(order);
      item = item.getNextComparatorItem();
    }
    if (orderList.isEmpty()) {
      return null;
    }
    return Sort.by(orderList);
  }
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);
	}
473851
public void addComparator(Comparator<T> comparator) {
		if (comparator instanceof InvertibleComparator) {
			this.comparators.add((InvertibleComparator<T>) comparator);
		}
		else {
			this.comparators.add(new InvertibleComparator<T>(comparator));
		}
	}
1301450
protected Collection<Method> sortMethods(Collection<Method> methods) {
        List<Method> list = new ArrayList<>(methods);
        Collections.sort(list, (m1, m2) -> {
            int o1 = Integer.MAX_VALUE;
            Order order1 = ClassUtil.getAnnotation(m1, Order.class);
            if (order1 != null) {
                o1 = order1.value();
            }

            int o2 = Integer.MAX_VALUE;
            Order order2 = ClassUtil.getAnnotation(m2, Order.class);
            if (order2 != null) {
                o2 = order2.value();
            }

            if (o1 == o2) {
                // same or unsorted, compare controller+method
                String s1 = Util.toString(m1);
                String s2 = Util.toString(m2);
                return s1.compareTo(s2);
            }

            if (o1 < o2) {
                return -1;
            } else {
                return 1;
            }
        });

        return list;
    }
1102369
public SortedSet<TypeElement> implementingClasses(TypeElement typeElement) {
        SortedSet<TypeElement> result = get(implementingClasses, typeElement);
        SortedSet<TypeElement> intfcs = allSubClasses(typeElement, false);

        // If class x implements a subinterface of typeElement, then it follows
        // that class x implements typeElement.
        Iterator<TypeElement> subInterfacesIter = intfcs.iterator();
        while (subInterfacesIter.hasNext()) {
            Iterator<TypeElement> implementingClassesIter
                    = implementingClasses(subInterfacesIter.next()).iterator();
            while (implementingClassesIter.hasNext()) {
                TypeElement c = implementingClassesIter.next();
                if (!result.contains(c)) {
                    result.add(c);
                }
            }
        }
        return result;
    }
1157763
@NotNull
    @SuppressWarnings("unchecked")
    public static <T extends Comparable<? super T>> ComparatorCompat<T> reverseOrder() {
        return (ComparatorCompat<T>) REVERSE_ORDER;
    }
1258114
public List<K> getKeysSortedByValue( final Comparator<V> comparator ) {
        synchronized ( _map ) {
            @SuppressWarnings( "unchecked" )
            final
            Entry<K, ManagedItem<V>>[] a = _map.entrySet().toArray( new Map.Entry[_map.size()] );
            final Comparator<Entry<K, ManagedItem<V>>> c = new Comparator<Entry<K, ManagedItem<V>>>() {

                @Override
                public int compare( final Entry<K, ManagedItem<V>> o1, final Entry<K, ManagedItem<V>> o2 ) {
                    return comparator.compare( o1.getValue()._value, o2.getValue()._value );
                }

            };
            Arrays.sort(a, c);
            return new LRUCache.ArrayList<K, V>( a );
        }
    }
459733
protected List<String> getClassKeyword(TypeElement typeElement) {
        ArrayList<String> metakeywords = new ArrayList<>(1);
        String cltypelower = config.utils.isInterface(typeElement) ? "interface" : "class";
        metakeywords.add(config.utils.getFullyQualifiedName(typeElement) + " " + cltypelower);
        return metakeywords;
    }
30055
static <T, S extends Sequence> Comparator<Cluster<T>>
    getComparatorOfClusters(final Comparator<T> objectComparator, final SequenceExtractor<T, S> extractor) {
        return new Comparator<Cluster<T>>() {
            @Override
            public int compare(Cluster<T> o1, Cluster<T> o2) {
                int i = objectComparator.compare(o2.head, o1.head); // Reverse comparison
                return i == 0 ?
                        extractor.getSequence(o2.head).compareTo(extractor.getSequence(o1.head))
                        : i;
            }
        };
    }
1102204
List<Method> getSortedCandidateMethods(String methodName, Method[] methods) {
		List<Method> candidates = new ArrayList<>();
		for (Method method : methods) {
			if (method.getName().equals(methodName)) {
				candidates.add(method);
			}
		}
		Collections.sort(candidates, comparator);
		return candidates;
	}
149520
public static <T> TypeChecker<List<? extends T>> tList(Class<? extends T> elementType) {
        return tList(tSimple(elementType));
    }
667170
private static SortedMap<TypeElement, List<TypeElement>> getPresenterBinders(List<TypeElement> presentersContainers) {
		Map<TypeElement, TypeElement> extendingMap = new HashMap<>();

		for (TypeElement presentersContainer : presentersContainers) {
			TypeMirror superclass = presentersContainer.getSuperclass();

			TypeElement parent = null;

			while (superclass.getKind() == TypeKind.DECLARED) {
				TypeElement superclassElement = (TypeElement) ((DeclaredType) superclass).asElement();

				if (presentersContainers.contains(superclassElement)) {
					parent = superclassElement;
					break;
				}

				superclass = superclassElement.getSuperclass();
			}

			extendingMap.put(presentersContainer, parent);
		}

		// TreeMap for sorting
		SortedMap<TypeElement, List<TypeElement>> elementListMap = new TreeMap<>(TYPE_ELEMENT_COMPARATOR);

		for (TypeElement presentersContainer : presentersContainers) {
			ArrayList<TypeElement> typeElements = new ArrayList<>();
			typeElements.add(presentersContainer);

			TypeElement key = presentersContainer;
			while ((key = extendingMap.get(key)) != null) {
				typeElements.add(key);
			}

			elementListMap.put(presentersContainer, typeElements);
		}
		return elementListMap;
	}
253767
public static boolean hasSameComparator(Comparator<?> comparator, Iterable<?> elements) {
    checkNotNull(comparator);
    checkNotNull(elements);
    Comparator<?> comparator2;
    if (elements instanceof SortedSet) {
      comparator2 = comparator((SortedSet<?>) elements);
    } else if (elements instanceof SortedIterable) {
      comparator2 = ((SortedIterable<?>) elements).comparator();
    } else {
      return false;
    }
    return comparator.equals(comparator2);
  }
208844
@Override
    public <T extends GraphQLType> Comparator<? super T> getComparator(SchemaPrinterComparatorEnvironment environment) {
        Comparator<?> comparator = registry.get(environment);
        if (comparator != null) {
            //noinspection unchecked
            return (Comparator<? super T>) comparator;
        }
        comparator = registry.get(environment.transform(builder -> builder.parentType(null)));
        if (comparator != null) {
            //noinspection unchecked
            return (Comparator<? super T>) comparator;
        }
        return DEFAULT_COMPARATOR;
    }
1160619
@Deprecated
  public static <T extends Comparable> Comparator<T> comparable()
  {
    return new Comparator<T>()
    {
      @Override
      public int compare(T t, T t1)
      {
        return t.compareTo(t1);
      }
    };
  }
1285317
static <T, S extends Sequence> Comparator<T>
    getComparatorOfObjectsRegardingSequences(final Comparator<T> objectComparator, final SequenceExtractor<T, S> extractor) {
        return new Comparator<T>() {
            @Override
            public int compare(T o1, T o2) {
                int i = objectComparator.compare(o2, o1);  // Reverse comparison
                return i == 0 ?
                        extractor.getSequence(o2).compareTo(extractor.getSequence(o1))
                        : i;
            }
        };
    }