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));
        }
Esempio n. 2
0
 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));
     };
 }
Esempio n. 3
0
 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)));
     };
 }
Esempio n. 4
0
 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));
 }