private static IOrderedDataProducer <TSource> ThenBy <TSource, TKey>(IOrderedDataProducer <TSource> source, DotNet20.Func <TSource, TKey> selector, IComparer <TKey> comparer, bool descending)
        {
            comparer.ThrowIfNull("comparer");
            IComparer <TSource> itemComparer = new ProjectionComparer <TSource, TKey>(selector, comparer);

            if (descending)
            {
                itemComparer = itemComparer.Reverse();
            }
            itemComparer = new LinkedComparer <TSource>(source.Comparer, itemComparer);
            return(new OrderedDataProducer <TSource>(source, itemComparer));
        }
 /// <summary>
 /// Further orders the values from an ordered data-source by a transform on each term, descending
 /// (the sort operation is only applied once for the combined ordering)
 /// </summary>
 /// <param name="source">The original data-producer and ordering</param>
 /// <param name="selector">Returns the value (for each term) by which to order the sequence</param>
 /// <param name="comparer">Comparer to compare the selected values</param>
 /// <returns>A data-producer that yeilds the sequence ordered
 /// by the selected value</returns>
 /// <remarks>This will force all data to be buffered</remarks>
 public static IOrderedDataProducer <TSource> ThenByDescending <TSource, TKey>(this IOrderedDataProducer <TSource> source, DotNet20.Func <TSource, TKey> selector, IComparer <TKey> comparer)
 {
     return(ThenBy(source, selector, comparer, true));
 }
 /// <summary>
 /// Further orders the values from an ordered data-source by a transform on each term, descending
 /// (the sort operation is only applied once for the combined ordering)
 /// </summary>
 /// <param name="source">The original data-producer and ordering</param>
 /// <param name="selector">Returns the value (for each term) by which to order the sequence</param>
 /// <returns>A data-producer that yeilds the sequence ordered
 /// by the selected value</returns>
 /// <remarks>This will force all data to be buffered</remarks>
 public static IOrderedDataProducer <TSource> ThenByDescending <TSource, TKey>(this IOrderedDataProducer <TSource> source, Func <TSource, TKey> selector)
 {
     return(ThenBy(source, selector, Comparer <TKey> .Default, true));
 }
 /// <summary>
 /// Further orders the values from an ordered data-source by a transform on each term, ascending
 /// (the sort operation is only applied once for the combined ordering)
 /// </summary>
 /// <param name="source">The original data-producer and ordering</param>
 /// <param name="selector">Returns the value (for each term) by which to order the sequence</param>
 /// <returns>A data-producer that yeilds the sequence ordered
 /// by the selected value</returns>
 /// <remarks>This will force all data to be buffered</remarks>
 public static IOrderedDataProducer <TSource> ThenBy <TSource, TKey>(this IOrderedDataProducer <TSource> source, DotNet20.Func <TSource, TKey> selector)
 {
     return(ThenBy(source, selector, Comparer <TKey> .Default, false));
 }
 /// <summary>
 /// Further orders the values from an ordered data-source by a transform on each term, ascending
 /// (the sort operation is only applied once for the combined ordering)
 /// </summary>
 /// <param name="source">The original data-producer and ordering</param>
 /// <param name="selector">Returns the value (for each term) by which to order the sequence</param>
 /// <param name="comparer">Comparer to compare the selected values</param>
 /// <returns>A data-producer that yeilds the sequence ordered
 /// by the selected value</returns>
 /// <remarks>This will force all data to be buffered</remarks>
 public static IOrderedDataProducer <TSource> ThenBy <TSource, TKey>(this IOrderedDataProducer <TSource> source, Func <TSource, TKey> selector, IComparer <TKey> comparer)
 {
     return(ThenBy(source, selector, comparer, false));
 }