什么排序算法是由LINQ"排序依据"? [英] What Sorting Algorithm Is Used By LINQ "OrderBy"?

查看:181
本文介绍了什么排序算法是由LINQ"排序依据"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然LINQ的排序依据原本被指定为不稳定,但海怪的时候它被指定为稳定。并非所有的文档进行了相应的更新 - 考虑到这些链接:

Evidently LINQ's "OrderBy" had originally been specified as unstable, but by the time of Orca it was specified as stable. Not all documentation has been updated accordingly - consider these links:

  • Jon Skeet on OrderBy stability
  • Troy Magennis on OrderBy stability

但如果LINQ的排序依据现在是稳定的,那么就意味着它不使用快速排序(这是内在的不稳定性),即使有些文件(如特洛伊的书)说,这是。所以我的问题是:如果不快速排序,那么什么是LINQ的排序依据是使用实际的算法

But if LINQ's OrderBy is now "stable," then it means it is not using a quicksort (which is inherently unstable) even though some documentation (e.g. Troy's book) says it is. So my question is: if not quicksort, then what is the actual algorithm LINQ's orderBy is using?

推荐答案

有关LINQ到对象,它是用于稳定快速排序。对于任何其他类型的LINQ的,它留给底层的实现。

For LINQ to Objects, it's a stable quicksort that is used. For any other kind of LINQ, it's left to the underlying implementation.

这篇关于什么排序算法是由LINQ"排序依据"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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