对于C#最好的排序算法/ .NET在不同的场景 [英] Best sorting algorithms for C# / .NET in different scenarios

查看:239
本文介绍了对于C#最好的排序算法/ .NET在不同的场景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是在C#中排序数据的最佳算法?

What are the best algorithms for sorting data in C#?

有一个分类算法,可以处理80%的种类呢?

Is there one sorting algorithm that can handle 80% of sorts well?

请给code的例子,如适用。

Please give code examples if applicable.

推荐答案

看看这个网站: 排序比较有Animtations

Check out this site: Sorting Comparisons with Animtations

简短的回答:快速排序

更长的答案: 上述网站会告诉你每种算法与一些漂亮的动画的长处和短处。

Longer answer: The above site will show you the strengths and weaknesses of each algorithm with some nifty animations.

简短的回答是没有最好四周排序(但你知道,因为你说80%的时间:)),但快速排序(或3路快速排序)可能会是你可以用最好的通用算法。

The short answer is there is no best all around sort (but you knew that since you said 80% of the time :) ) but QuickSort (or 3 Way Quick Sort) will probably be the best general algorithm you could use.

这是在.net列表中默认使用的算法,这样你就可以叫 .Sort 如果你有什么已经在列表中。

It is the algorithm used by default for Lists in .Net, so you can just call .Sort if what you have is already in a list.

还有我指着你,如果你想了解如何实现这个上面的网站上伪code。

There is pseudo-code on the website I pointed you to above if you want to see how to implement this.

这篇关于对于C#最好的排序算法/ .NET在不同的场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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