// Private constructor, the external creation is controlled by the factory methods below private ProperOrderedCollection(IEnumerable <T> original, ProperOrderedCollection <T> parent, IComparer <T> comparer) { this.original = original; this.parent = parent; this.comparer = comparer; }
// We're continuing to require the ordered field to implement IComparable & are using the // SimpleComparer. A full implementation would allow us to pass something like a // Func<T, T, int> so we could specify an ordering function in the call public static IOrderedEnumerable <T> ProperOrder <T, TOrderBy>(this IEnumerable <T> original, Func <T, TOrderBy> selector) where TOrderBy : IComparable <TOrderBy> { IComparer <T> comparer = new SimpleComparer <T, TOrderBy>(selector); return(ProperOrderedCollection <T> .Create(original, comparer)); }