Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# NET中是否有内置的稳定排序例程和交换函数?_C#_.net_Built In_Standard Library_Stable Sort - Fatal编程技术网

C# NET中是否有内置的稳定排序例程和交换函数?

C# NET中是否有内置的稳定排序例程和交换函数?,c#,.net,built-in,standard-library,stable-sort,C#,.net,Built In,Standard Library,Stable Sort,NET中有内置的稳定排序例程吗 < >我知道C++在“算法” STD::SoTo()/下有一个内置的排序例程。同样地,我们有什么东西可以和C#一起使用吗 另外,在.NET中是否有内置的交换功能?在Google中使用“C#稳定排序”显示了这篇SO帖子的最佳结果: 因此答案是:Enumerable.OrderBy是一个稳定的排序函数,不是内置在C#中,而是.NET framework库的一部分 关于“交换”:我不知道在.NET framework中有任何预构建的通用交换函数,但您可以在不到10行代

NET中有内置的稳定排序例程吗

< >我知道C++在“算法”<代码> STD::SoTo()/<代码>下有一个内置的排序例程。同样地,我们有什么东西可以和C#一起使用吗

另外,在.NET中是否有内置的交换功能?

在Google中使用“C#稳定排序”显示了这篇SO帖子的最佳结果:

因此答案是:
Enumerable.OrderBy
是一个稳定的排序函数,不是内置在C#中,而是.NET framework库的一部分

关于“交换”:我不知道在.NET framework中有任何预构建的通用交换函数,但您可以在不到10行代码中找到一个实现:

静态无效交换(左参考、右参考)
{
温度;
温度=lhs;
lhs=rhs;
rhs=温度;
}

STD::排序既不内置于C++,也不保证是稳定的。什么时候这个成为了内置的?C++中的稳定代码是<代码> STD::Stable排序> <代码>。在看到OrderBy是多么容易发现,并且看到你在这里问了两个完全不同的问题,我不得不去投票,抱歉。
static void Swap<T>(ref T lhs, ref T rhs)
{
    T temp;
    temp = lhs;
    lhs = rhs;
    rhs = temp;
}