thenByE<TKey> method
Adds a secondary sorting pass to enumeration in ascending (least-to-greatest) order.
thenByE applies to an enumerable that has been sorted by orderByE or orderByDescendingE (or another thenByE or thenByDescendingE). Once the previous sorting mechanism is processed, the keys are then sorted again using the EqualityComparer given to this method. (The process of sorting is identical to groupByE.)
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 ascending order. String
types will be sorted in 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 ascending order, the resulting enumerable will be unchanged.
Implementation
Enumerable<T> thenByE<TKey>(Selector<T, TKey> keySelector,
{EqualityComparer<TKey> keyComparer}) {
ArgumentError.checkNotNull(keySelector);
if (this is! InternalOrderedEnumerable) {
throw UnsupportedError(
'ThenBy must be called immediately following a call to OrderBy, OrderByDescending, ThenBy, or ThenByDescending.');
}
return (this as dynamic)
.createOrderedEnumerable<TKey>(keySelector, keyComparer, false);
}