哪个排序算法是IComparer的使用.NET算法、IComparer、NET

2023-09-04 00:57:10 作者:(ˉ﹃ˉ)

是否有任何人知道它的排序算法是使用.NET时,我们在类中实现的IComparer?

Do any one know which sorting algorithm is used by .net when we implement IComparer in our class?

推荐答案

快速排序好像是吧。

在的IComparer 文档说

该接口用于与的Array.Sort 和 Array.BinarySearch 方法。

借助的Array.Sort 文件说

此方法使用快速排序算法。此实现执行不稳定排序;也就是说,如果两个元素是相等的,它们的顺序可能不是preserved。与此相反,一个稳定的排序preserves中等于元素的顺序

This method uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.