Arrays.sort(Object[] a) - how is it implemented?
17,568
Here is the source of java.util.Arrays
.
Actually, you have that source code in the JDK - just open java.util.Arrays
in your IDE and the source code + the comments will appear. If you don't have an IDE, look at JDK_HOME\src.zip
Then, put it in your IDE and trace how it works.
- put breakpoints (and run a program in debug mode)
- use
System.out.println(..)
- change parts of it to see how they are reflected.
- read the wikipedia article about merge sort
- pay attention to this comment:
// Recursively sort halves of dest into src
Author by
helpermethod
Updated on August 08, 2022Comments
-
helpermethod over 1 year
Are there any resources on how the mergeSort used by Arrays.sort(Object[] a) is implemented? While it is documented quite good, I have a hard time understanding it (especially why the src and dest are are switched when mergeSort() get's recursively called).