TODO: This is similar to what OrderByOperator does, look into reusing this logic in OrderByOperator as well.
555894
public Iterator<Page> getSortedPages()
    {
        return new AbstractIterator<Page>()
        {
            private int currentPosition;
            private final PageBuilder pageBuilder = new PageBuilder(types);
            private final int[] outputChannels = new int[types.size()];

            {
                Arrays.setAll(outputChannels, IntUnaryOperator.identity());
            }

            @Override
            public Page computeNext()
            {
                currentPosition = buildPage(currentPosition, outputChannels, pageBuilder);
                if (pageBuilder.isEmpty()) {
                    return endOfData();
                }
                Page page = pageBuilder.build();
                pageBuilder.reset();
                return page;
            }
        };
    }
304577
public Swagger2MarkupConfigBuilder withOperationOrdering(Comparator<PathOperation> operationOrdering) {
        Validate.notNull(operationOrdering, "%s must not be null", "operationOrdering");
        config.operationOrderBy = OrderBy.CUSTOM;
        config.operationOrdering = operationOrdering;
        return this;
    }
1027612
function orderBy(expression) {

        //Check arguments
        if (!expression)
            throw new Error("Expression is invalid");
		
		//Define sort action estracting values from objects
		var sortAction = function(a, b){
		
			//Get value for "a" and "b" element
			var aValue = expression(a);
			var bValue = expression(b);
		
			//Check if one element is greater then the second one
			if(aValue < bValue) return -1;
			if(aValue > bValue) return 1;
			return 0;
		};
		
		//Copy array in order to avoid modifications on original
		var outData = [];
		for(var i = 0; i < this.items.length; i++){
			outData.push(this.items[i]);
		}

        //Define output array
        var sortedData = outData.sort(sortAction);
        
        //Return for chaining
        return new jslinq(sortedData);
    }
1328817
public BeanQuery<T> orderBy(String orderByProperty, Comparator propertyValueComparator) {
    this.comparator = new DelegatedSortOrderableComparator(new PropertyComparator(orderByProperty,
        propertyValueComparator));
    return this;
  }
311599
@Override
    public int compareTo(final AbstractAttr<T> otherObj) {
        if (otherObj == null) {
            return 1;
        } else {
            return value.compareTo(otherObj.value);
        }
    }
581003
@Override
    protected final List<Description> orderItems(Collection<Description> descriptions) {
        /*
         * In practice, we will never get here--Sorters do their work in the
         * compare() method--but the Liskov substitution principle demands that
         * we obey the general contract of Orderable. Luckily, it's trivial to
         * implement.
         */
        List<Description> sorted = new ArrayList<Description>(descriptions);
        Collections.sort(sorted, this); // Note: it would be incorrect to pass in "comparator"
        return sorted;
    }
599508
public CompositeScore<S> withRemainderOrdering(OrderingList<S> ordering) {
        return new CompositeScore<S>(mFilteringScore,
                                     mOrderingScore.withRemainderOrdering(ordering));
    }
155903
function processOperators (ops) {
    if (!ops) return {};
    var operators = {};
    for (var i=0,k,prec;prec=ops[i]; i++) {
        for (k=1;k < prec.length;k++) {
            operators[prec[k]] = {precedence: i+1, assoc: prec[0]};
        }
    }
    return operators;
}
421850
@Override
    public int compareTo(ObserverMethod o) {
        if (o == null) {
            return 1;
        }
        Integer a = getPresedence(getMethod());
        Integer b = getPresedence(o.getMethod());
        return b.compareTo(a);
    }
744550
@Override
	public int compare(final E o1, final E o2) throws UnsupportedOperationException {
		if (lock == false) {
			checkChainIntegrity();
			lock = true;
		}
		
		final Iterator<Comparator<E>> comparators = chain.iterator();
		Comparator<? super E> comparator;
		int retval;
		for (int comparatorIndex = 0; comparators.hasNext(); ++comparatorIndex) {
			comparator = comparators.next();
			retval = comparator.compare(o1, o2);
			if (retval != 0) {
				// invert the order if it is a reverse sort
				if (true == orderingBits.get(comparatorIndex)) {
					retval = (retval > 0) ? -1 : 1;
				}
				return retval;
			}
		}

		// if comparators are exhausted, return 0
		return 0;
	}
679311
function(o)
    {
        var q = this.clone();
        q._orderBy = o;
        q._ascending = true;
        return q;
    }
195967
public static <T> OrderBy<T> convertToEbeanOrderBy(Sort sort) {
        if (sort == null) {
            return null;
        }
        List<String> list = new ArrayList<>();

        Iterator<Sort.Order> orderIterator = sort.iterator();
        while (orderIterator.hasNext()) {
            Sort.Order so = orderIterator.next();
            list.add(so.getProperty() + " " + so.getDirection());
        }
        return new OrderBy<T>(StringUtils.collectionToCommaDelimitedString(list));
    }
715993
function firstOrDefault(predicate, defaultValue) {
  predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate;

  for (let item of this) {
    if (predicate(item)) return item;
  }

  return defaultValue;
}
207196
public static <K, V extends Comparable<V>> Ordering<Map.Entry<K, V>> byValueOrderingDescending() {
    return Ordering.<V>natural().onResultOf(MapUtils.<K, V>getEntryValue()).reverse();
  }
1202804
def commutator_order(cls, ops, kwargs):
    
    from qnet.algebra.core.operator_algebra import Commutator
    assert len(ops) == 2
    if cls.order_key(ops[1]) < cls.order_key(ops[0]):
        return -1 * Commutator.create(ops[1], ops[0])
    else:
        return ops, kwargs
445130
public static Comparator<LongTuple> comparator(Order order)
    {
        if (order == Order.LEXICOGRAPHICAL)
        {
            return (t0, t1) -> compareLexicographically(t0, t1);
        }
        if (order == Order.COLEXICOGRAPHICAL)
        {
            return (t0, t1) -> compareColexicographically(t0, t1);
        }
        return null;
    }
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);
    }