public static IOrderedEnumerable <TSource> OrderBy <TSource, TKey>(
            this IEnumerable <TSource> source,
            Func <TSource, TKey> keySelector,
            IComparer <TKey> comparer)
        {
            if (source == null || keySelector == null)
            {
                throw new ArgumentNullException("source or selector is null");
            }

            IComparer <TSource> sourceComparer = new CompareByKey <TSource, TKey>(keySelector, comparer);

            return(new OrderedEnumerable <TSource>(source, sourceComparer));
        }
        public IOrderedEnumerable <TElement> CreateOrderedEnumerable <TKey>(Func <TElement, TKey> keySelector,
                                                                            IComparer <TKey> comparer,
                                                                            bool descending)
        {
            if (keySelector == null)
            {
                throw new ArgumentNullException("keySelector is null");
            }

            IComparer <TElement> secondaryComparer =
                new CompareByKey <TElement, TKey>(keySelector, comparer);

            return(new OrderedEnumerable <TElement>(source,
                                                    new CompareObjects <TElement>(currentComparer, secondaryComparer)));
        }