.NET 4.5 changed the implementation of Array.Sort to what is called "introspective sort" which is a hybrid algorithm, consisting of choosing between quicksort, insertionsort, and heapsort depending on the input data. It is detailed here:
http://msdn.microsoft.com/en-us/library/6tf1f0bc(v=vs.110).aspx
It is well documented that the sort is "unstable", meaning two elements containing the same sort order value may or may not preserve the order from the original input. However, I need to know whether or not it is "deterministic", in the sense that any arbitrary input data will reproducibly return the same output data every time it is sorted. Specifically, I know that quicksort can be implemented either deterministically or non-deterministically (if the pivot is chosen at random), but I'm not sure which implementation is used for .NET's introspective sort.
From my testing, it seems to be deterministic, as I have not seen any particular set of data return differently between runs, but obviously you can't prove something doesn't exist simply because you haven't seen it :-/
I suppose I plan on looking at the code to help try to figure out whether or not introspective sort is deterministic, but I was hoping that someone here knows offhand and can save me the effort ;)
Thanks! Ryan
Array.Sortpage that the algorithm is deterministic, is is very risky to rely on it. After all, you just saw 4.5 change the algorithm. It can change again.