OrderBy and Top in LINQ with good performance
问题 What is a good way to get the top 10 records from a very large collection and use a custom OrderBy? If I use the LINQ to Objects OrderBy method it is slow and takes a lot of memory because it creates an entire new collection with the new order. I would like a new method with the signature below that does not re-order the entire collection and is very fast: public static IEnumerable<TSource> OrderByTop<TSource, TKey>( IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey