I need to bench mark my quick sort algorithm with an inbuilt java sort. Since I am using arraylists and linkedlists, I need an inbuilt java sort that would sort with quick sort.
I have tried Arrays.sort(), but there doesn't seem to work for array and linked lists as arguments.
And also from Why does Collections.sort use Mergesort but Arrays.sort does not? It is said that the collections.sort() uses merge sort, and that there isn't any inbuilt sort for non primitive types that uses quick sort cause of stability requirements.
So how might I use an inbuilt java algorithm that uses Quicksort to sort arraylist and linkedlists?
Would it be a way to reverse the test-procedure?
Modify your sorting algorithm to work with an array and use Arrays.sort()
to match it.
Both classes – ArrayList
and LinkedList
– are having a toArray()
function.
Arrays.sort()
calls java.util.ComparableTimSort.sort()
internally.