Java:JDK7中Arrays.sort()和Collections.sort()中排序算法的变化

从JDK7开始,Arrays.sort()和Collections.sort()中排序算法发生了变化:

JDK7以前
---------------------
Arrays.sort(Object[] a) & Collections.sort(List list)
modified mergesort

Arrays.sort([] a)
tuned quicksort


JDK7开始
---------------------
Arrays.sort(Object[] a) & Collections.sort(List list)
TimSort

Arrays.sort([] a)
Dual-Pivot Quicksort

JDK7中两种算法的实现类:
java.util.DualPivotQuicksort
java.util.TimSort
java.util.ComparableTimSort

 

参考文档

Dual-Pivot QuickSort:
https://arxiv.org/pdf/1511.01138.pdf
Timsort:
https://sikasjc.github.io/2018/07/25/timsort/

单轴快排(SinglePivotQuickSort)和双轴快排(DualPivotQuickSort)及其JAVA实现
https://blog.csdn.net/Holmofy/article/details/71168530

你可能感兴趣的:(Java,sort)