The are several sorting algorithms like inserstion sort, selection sort, bubble sort etc. that are often discussed in computer science textbooks. Given an array of integers or objects, are there built-in Java 6 language API that let me choose to apply a specfic sort algorithm to sort the array instead of me reinventing these wheels again? If not built into Java 6, are there open source libraries that prodivde this functionality and what are they?
The are several sorting algorithms like inserstion sort, selection sort, bubble sort etc. that
Share
The
Arrays.sort()methods use a quick sort in all primitive type arrays.The
Collections.sort()method uses a merge sort. This sort is also used inArrays.sort(Object[])andArrays.sort(T[], Comparator<? super T>).