How does OpenJDK internally sort the datatypes and why ? It would be great if the specific algorithms can be mentioned
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Beginning with version 7, Oracle’s Java implementation is using Timsort for object arrays bigger than 10 elements, and Insertion sort for arrays with less than that number of elements. The same considerations apply for both
Arrays.sort()andCollections.sort(). In older versions of Java, Merge sort was used instead of Timsort.Other implementations of the language (other than Oracle’s) might use a different sorting algorithm, as this is not mandated by the specification. Quoting
Collections‘ documentation:For sorting numeric primitives, JDK 7 uses “dual pivot quicksort”.