Just wondering why Java
and .NET Framework
uses different sorting algorithm by default.
In Java Array.Sort()
uses Merge Sort algorithm by default and as Wikipedia.com says:
In Java, the Arrays.sort() methods use merge sort or a tuned quicksort depending on the datatypes and for implementation efficiency switch to insertion sort when fewer than seven array elements are being sorted
In .NET Framework Array.Sort/List.Sort()
uses Quick Sort as default sorting algorithm (MSDN):
List.Sort() uses Array.Sort, which uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.
By looking at the great "Comparison of algorithms" table we can see that both algorithms has pretty different behaviour from Worst Case and Memory Usage perspectives:
Both Java
and .NET
are great Frameworks for Enterprise Solutions development, both has platforms for embedded development. So why they are using different sorting algorithm by default, any thoughts?
EDIT: I see that two persons already voted to close this quesion as not constructive. I believe Java and .NET are most popular development Frameworks so it would be really interesting to find any non trivial and interesting thoughts, perhaps facts!, regarding such decision.
Different development teams in two different companies came to different conclusions regarding the usual use case for their frameworks and components and have decided to implement accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With