Using an array of Comparators, applied in sequence until one returns not equal or the array is exhausted.
960412
public BeanQuery<T> orderBy(Comparator... beanComparator) {
    this.comparator = new DelegatedSortOrderableComparator(ComparatorUtils.chainedComparator(beanComparator));
    return this;
  }
985408
public static <E extends Comparable<E>> void sort(E[] array) {
        int index = 0;
        E value = null;
        
        for(int i = 1; i < array.length; i++) {
            index = i;
            value = array[index];

            while(index > 0 && value.compareTo(array[index - 1]) < 0) {
                array[index] = array[index - 1];
                
                index--;
            }
            
            array[index] = value;
        }
    }
1042591
public static <T> Sequence<T> sort(final Sequence<T> sequence, final Comparator<T> comparator)
  {
    List<T> seqList = Sequences.toList(sequence, Lists.<T>newArrayList());
    Collections.sort(seqList, comparator);
    return BaseSequence.simple(seqList);
  }
800519
@SuppressWarnings({ "unchecked" })
	protected int compare(E k1, E k2) {
		if (comparator == null) {
			return ((Comparable) k1).compareTo(k2);
		}
		return comparator.compare(k1, k2);
	}
1118659
function(arr, iterator) {
  var i = arr.length - 1, index = null

  if(i >= 0){
    do {
      if(iterator(arr[i])) {
        index = i
        break
      }
    } while(i--)
  }

  return index
}
846389
function shortBubbleSort(array, comparatorFn) {
  const comparator = new Comparator(comparatorFn);
  const length = array.length - 1;
  let i = 0;

  for (i; i < length; i++) {
    const current = array[i];
    const next = array[i + 1];

    /**
     * If the current value if greater than the next:
     * - set current value to next value;
     * - and set next value to current value;
     * - then reset iterator counter to rescan for values to be sorted.
     */

    if (comparator.greaterThan(current, next)) {
      array[i + 1] = current;
      array[i] = next;
      i = -1;
    }
  }

  return array;
}
463284
public static <T extends Comparable<? super T>>  int[] sort(T[] arr) {
        int[] order = new int[arr.length];
        for (int i = 0; i < order.length; i++) {
            order[i] = i;
        }
        sort(arr, order);
        return order;
    }
999674
private E dequeue() {
        int n = size - 1;
        if (n < 0)
            return null;
        else {
            Object[] array = queue;
            E result = (E) array[0];
            E x = (E) array[n];
            array[n] = null;
            Comparator<? super E> cmp = comparator;
            if (cmp == null)
                siftDownComparable(0, x, array, n);
            else
                siftDownUsingComparator(0, x, array, n, cmp);
            size = n;
            return result;
        }
    }
1098868
public static <T> int compare(T a, T b, Comparator<? super T> c) {
        if (a == b) {
            return 0;
        }
        return c.compare(a, b);
    }
614273
function(comparator, comparatorNullsFirst)
  {
    var cmp = comparator ? createComparator( comparator, comparatorNullsFirst ) : this.comparator;

    if ( !isSorted( cmp, this ) )
    {
      this.map.sort( cmp );

      this.trigger( Collection.Events.Sort, [this] );
    }

    return this;
  }
757926
public static <E extends Comparable<E>> void sortDescending(E[] array) {
        while(!Sort.isReverseSorted(array)) {
            FYShuffle.shuffle(array);
        }
    }
838247
private void fixupMaxWithComparator(int k) {
        K key = array[k];
        int gp = k / 4;
        while (gp > 0 && comparator.compare(array[gp], key) < 0) {
            array[k] = array[gp];
            k = gp;
            gp = k / 4;
        }
        array[k] = key;
    }
239840
function multipleComparators(comparators) {
    return function applyComparators(a, b) {
        var i,
            result;

        for (i = 0; i < comparators.length; i++) {
            result = comparators[i](a, b);
            if (result !== 0) {
                return result;
            }
        }

        return defaultComparator(a, b);
    };
}
352993
public static <T> Comparator<T> comparator(CheckedComparator<T> comparator) {
        return Unchecked.comparator(comparator, Unchecked.RETHROW_ALL);
    }
1314626
private static <T> ArrayList<T> sorted(Collection<T> cls, Comparator<? super T> c) {
    ArrayList<T> sorted = new ArrayList<>(cls);
    sorted.sort(c);
    return sorted;
  }
393761
static int compare (final Date nextFireTime1,
                        final int priority1,
                        final TriggerKey key1,
                        final Date nextFireTime2,
                        final int priority2,
                        final TriggerKey key2)
    {
      if (nextFireTime1 != null || nextFireTime2 != null)
      {
        if (nextFireTime1 == null)
          return 1;
        if (nextFireTime2 == null)
          return -1;
        if (nextFireTime1.before (nextFireTime2))
          return -1;
        if (nextFireTime1.after (nextFireTime2))
          return 1;
      }

      int comp = priority2 - priority1;
      if (comp == 0)
        comp = key1.compareTo (key2);
      return comp;
    }
57304
@SafeVarargs
    public static <V extends Comparable<V>> V[] sort(V... array) {
        Arrays.sort(array);
        return array;
    }