Sorting an Array
Let's see how we can sort an array using the sort() method of the Arrays class.
We'll cover the following...
We'll cover the following...
The Arrays class has a sort()
method that is used to sort the arrays of objects and primitives. If we are sorting a primitive array, then quicksort is used. And if we are sorting an object array, then merge sort is used.
Although quicksort is faster in both cases, it is not a stable algorithm. Merge sort is a stable algorithm, so it is used in the ...