r/programming • • Apr 04 '17

Sorting in .NET

http://codingsight.com/sorting-in-net/
13 Upvotes

13 comments sorted by

4

u/d_kr Apr 04 '17

Wow, I did not expect an in depth sort implementation comparision. Thankfully it is not a "101 some sort implementation in c#".

1

u/mrexodia Apr 04 '17

What about Array.Sort?

1

u/[deleted] Apr 04 '17

it uses the introspective sort: https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Array.cs

also, random tip, if you want to do Array.Sort in descending order, you can make a generalized reverse comparer, and create and extension method for it:

https://github.com/jackmott/LinqFaster/blob/master/LinqFaster/Utils/ComparerMagic.cs#L11

1

u/_Mardoxx Apr 04 '17 edited Apr 06 '17

Why does it decreqse increase in performance when you install visual studio?

2

u/FrzTmto Apr 05 '17

Added calls are present to update stats so when Visual Studio is running, those are fed into the graphics that are shown (CPU use, etc.). You want information while developing, and users without VS will get a good speed because those components are more oriented to performance.

1

u/_Mardoxx Apr 06 '17

Performance increases when VS is installed. So I was wrong.

2

u/Sebazzz91 Apr 05 '17

It does not. Execution time is lower.

1

u/_Mardoxx Apr 06 '17

Well then same questiom but conversely

1

u/[deleted] Apr 05 '17

[removed] — view removed comment

1

u/Danthekilla Apr 06 '17

But it gets faster... Not slower.

1

u/jogai-san Apr 05 '17

Can be easily combined with cashing

Nice feature. Does it cache though?