所使用的.NET的`的Array.Sort()`方法稳定的算法排序算法? [英] Is the sorting algorithm used by .NET's `Array.Sort()` method a stable algorithm?

查看:200
本文介绍了所使用的.NET的`的Array.Sort()`方法稳定的算法排序算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时使用.NET的的Array.Sort()方法的稳定算法?

Is the sorting algorithm used by .NET's Array.Sort() method a stable algorithm?

推荐答案

MSDN

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

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.

排序使用内省排序。 (快速排序在4.0及更早版本的.NET Framework的版本)。

The sort uses introspective sort. (Quicksort in version 4.0 and earlier of the .NET framework).

如果你需要一个稳定的排序,你可以使用 Enumerable.OrderBy

If you need a stable sort, you can use Enumerable.OrderBy.

这篇关于所使用的.NET的`的Array.Sort()`方法稳定的算法排序算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆