JDK 7 uses Tim sort for object array. Which algorithm used for primitive array sort ?
Asked
Active
Viewed 270 times
-1
-
4Why not read [the javadoc](https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#sort(int[]))? – assylias Nov 05 '16 at 13:16
-
See also [“Why does Collections.sort use Mergesort but Arrays.sort does not?”](http://stackoverflow.com/questions/32334319/why-does-collections-sort-use-mergesort-but-arrays-sort-does-not/32334651#32334651) – Holger Nov 07 '16 at 11:23
2 Answers
0
Java uses Dual-pivot QuickSort to sort array containing primitive data. And it uses Insertion sort if size of array is small (less than 17) and if the size of array is greater than 17 it uses TimSort (Also know as "variation of merge sort") to sort the array containing the object.
Tim sort is also used in sorting of collections in java.

Naman jain
- 66
- 11