No generic version of DualPivotQuickSort

Louis Wasserman lowasser at google.com
Mon Jan 26 21:01:44 UTC 2015


My understanding was that the performance difference wasn't perceived to
outweigh the user confusion risks associated with multiple sorting
algorithm options. Right now, only one option is presented -- a stable sort
-- and that algorithm is intended to be *nearly* as fast as an unstable
sort, and unstable sorting algorithms are *subtly* unsuitable for some use
cases in a way that might be hard for users to debug or realize why their
code is buggy.

Is that an accurate assessment?

On Mon Jan 26 2015 at 12:55:18 PM Buis, Paul <00pebuis at bsu.edu> wrote:

> The java.util.DualPivotQuicksort class implements sort() methods for the
> primitive types, has no methods that deal with generic arrays with methods
> like
>
> static <T extends Comparable<? super T>> void sort(T[] array, int iStart,
> int iEnd)
>
> or
>
> static <T extends Comparable<? super T>> void sort(T[] a, int left, int
> right, T[] work, int workBase, int workLen)
>
> Similarly, it contains no methods for Comparator-based sorting of generic
> arrays. Might it make sense to add such methods to DualPivotQucksort? The
> Arrays.sort() methods for generic arrays use TimSort which is likely to be
> slower. TimSort is stable and DualPivotQuickSort is not. Might it make
> sense to allow the user to pick a stable or an unstable version of a
> generic Arrays.sort() and use TimSort when stability is desired and
> DualPivotQuicksort when it is not?
>



More information about the core-libs-dev mailing list