public static IOrderingImpl <T> ThenByDescending <T, TKey>(this IOrderingImpl <T> source, Func <T, TKey> comparer) where TKey : IComparable <TKey> { Comparison <T> descendingComparer = (left, right) => comparer(right).CompareTo(comparer(left)); return(new MyOrderedEnumerable <T, TKey>(source, descendingComparer)); }
public MyOrderedEnumerable(IOrderingImpl <T> source, Comparison <T> comparison) { this.source = source; this.comparison = (a, b) => { var originalComparison = source.CompareTo(a, b); if (originalComparison != 0) { return(originalComparison); } return(comparison(a, b)); }; }
public MyOrderedEnumerable(IOrderingImpl <T> source, Func <T, TKey> comparer) { this.source = source; comparison = (a, b) => { var originalComparison = source.CompareTo(a, b); if (originalComparison != 0) { return(originalComparison); } return(comparer(a).CompareTo(comparer(b))); }; }
public static IOrderingImpl <T> MyThenBy <T, TKey>(this IOrderingImpl <T> source, Func <T, TKey> comparer) where TKey : IComparable <TKey> { return(new MyOrderedEnumerable <T, TKey>(source, comparer)); }