我正在研究“ timsort”算法,以便对相当大的数据集进行一些排序: http://timsort4net.codeplex.com/

通常,我使用Array.Sort(Keys, Items),其中Items是一个整数数组,用作识别排序期间发生的位置变化的方法。

有什么方法可以达到相同的结果而无需大量修改排序算法的实现?

有帮助吗?

解决方案

You could use the extension method defined on IList

public static void TimSort<T>(this IList<T> array, Comparison<T> comparer, bool buffered = true)

to sort the list of indices, and pass in a Comparison that references the real objects given the indices, compares them and returns negative, positive or zero values.

Hope this helps!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top