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).
Are there any resources on how the mergeSort used by Arrays.sort(Object[] a) is implemented?
Share
Here is the source of
java.util.Arrays.Actually, you have that source code in the JDK – just open
java.util.Arraysin your IDE and the source code + the comments will appear. If you don’t have an IDE, look atJDK_HOME\src.zipThen, put it in your IDE and trace how it works.
System.out.println(..)// Recursively sort halves of dest into src