orderByDescendingE<TKey> method

Enumerable<T> orderByDescendingE <TKey>(Selector<T, TKey> keySelector, { EqualityComparer<TKey> keyComparer })

Sorts the enumeration in descending (greatest-to-least) order.

First, orderByDescendingE iterates over the entire enumerable, creating a list of keys generated by keySelector associated to their corresponding elements. Then a QuickSort algorithm is applied to the keys, using the sorter property in keyComparer to determine sort order. Afterwards, the resulting enumerable will consist of the elements in the source enumerable in the order determined by the sorted list of keys.

When the type of the enumerable is one of the below types, the EqualityComparer can be omitted. In this case, the function defaults to predefined minimum functions depending on the type:

  • Numeric types (num, int, double) will be sorted by their values in descending order.
  • String types will be sorted in reverse-alphabetic order.

If the enumerable type is not one of these types and the EqualityComparer is not provided, the order of the resulting enumerable is unpredictable.

If the enumerable is already sorted in descending order, the resulting enumerable will be unchanged.

Implementation

Enumerable<T> orderByDescendingE<TKey>(Selector<T, TKey> keySelector,
    {EqualityComparer<TKey> keyComparer}) {
  assert(keySelector != null);
  return InternalOrderedEnumerable(this, keySelector, keyComparer, true);
}