Пример #1
0
        public IOrderedEnumerable <T> CreateOrderedEnumerable <TKey>(Func <T, TKey> keySelector, IComparer <TKey> keyComparer, bool descending)
        {
            var secondComparer = new MyComparer <T, TKey>(keySelector, keyComparer);

            Comparers.Add(secondComparer);
            return(new MyOrderedEnumerable <T>(this, Comparers));
        }
Пример #2
0
        public static IOrderedEnumerable <TSource> OrderBy <TSource, TKey>(
            this IEnumerable <TSource> source,
            Func <TSource, TKey> keySelector,
            IComparer <TKey> keyComparer)
        {
            EnsureArgumentIsNotNull(source, nameof(source));
            EnsureArgumentIsNotNull(keySelector, nameof(keySelector));


            var myComparer    = new MyComparer <TSource, TKey>(keySelector, keyComparer);
            var comparersList = new List <IComparer <TSource> >();

            comparersList.Add(myComparer);
            return(new MyOrderedEnumerable <TSource>(source, comparersList));
        }