Take the 2-minute tour ×  Arrays.java's sort method uses
quicksort for arrays of primitives and merge sort for arrays of
objects. I believe that most of time quicksort is faster than
merge sort and costs less memory. My experiments support that,
although both algorithms are O(nlog(n)). So why are different
algorithms used for different types?  share|improve this
question Quicksort worst case is N^2 not NlogN. –  codaddict Sep
14 '10 at 8:27 Wait, what happens if you have an array of
Integers or something? –  Tikhon Jelvis Sep 14 '10 at 8:30 Isn't
this explained in the source you read? –  Humphrey Bogart Sep 14
'10 at 10:11  3 Answers 3  up vote 70 down vote accepted  The
most likely reason: quicksort is not stable, i.e. equal entries
can change their relative position during the sort; among other
things, this means that if you sort an already sorted array, it
may not stay unchanged.  Since primitive types have no identity
(there is no way to distinguish two ints with the same value),
this does not matter for