Skip to content

Conversation

@LilithHafner
Copy link
Member

Previously, DEFAULT_STABLE was a giant chain of algorithms reflecting the full sorting dispatch system. Now, it's simply DefaultStable(). This has a few minor impacts:

Previously, the public binding Base.Sort.DEFAULT_STABLE documented non-public implementation details of sorting dispatch in its extended help with a caviat that they are internal. Now, Base.Sort.DEFAULT_STABLE refers to the non-public binding Base.Sort.DefaultStable and implementation details are documented there with a warning that they are non-public.

Previously, dispatching on Base.Sort.DEFAULT_STABLE required writing ::typeof(Base.Sort.DEFAULT_STABLE) whereas now one could alternatively dispatch on the (internal) type Base.Sort.DefaultStable.

Previously Base.Sort.DEFAULT_STABLE === Base.Sort.DEFAULT_UNSTABLE so when writing sorting algorithms for custom collections it was impossible to determine if the user asked for a stable algorithm. Now DEFAULT_STABLE is DefaultStable() and DEFAULT_UNSTABLE is DefaultUnstable(). Both the algorithms expand to the same large chain of algorithms _DEFAULT_ALGORITHMS_FOR_VECTORS but it is possible to intercept them before that happens.

Base.Sort.DEFAULT_STABLE now prints as DefaultStable() instead of

julia> Base.Sort.DEFAULT_STABLE
Base.Sort.SubArrayOptimization(
    Base.Sort.MissingOptimization(
        Base.Sort.BoolOptimization(
            Base.Sort.Small{10}(
                Base.Sort.InsertionSortAlg(),
                Base.Sort.IEEEFloatOptimization(
                    Base.Sort.IsUIntMappable(
                        Base.Sort.Small{40}(
                            Base.Sort.InsertionSortAlg(),
                            Base.Sort.CheckSorted(
                                Base.Sort.ComputeExtrema(
                                    Base.Sort.ConsiderCountingSort(
                                        Base.Sort.CountingSort(),
                                        Base.Sort.ConsiderRadixSort(
                                            Base.Sort.RadixSort(),
                                            Base.Sort.Small{80}(
                                                Base.Sort.InsertionSortAlg(),
                                                Base.Sort.ScratchQuickSort(missing, missing,
                                                    Base.Sort.InsertionSortAlg()))))))),
                        Base.Sort.StableCheckSorted(
                            Base.Sort.ScratchQuickSort(missing, missing,
                                Base.Sort.InsertionSortAlg()))))))))

Factored out of #54494 at Triage's request (the git history reflects this history).

@LilithHafner LilithHafner added the sorting Put things in order label Nov 23, 2024
@LilithHafner LilithHafner merged commit a17db2b into master Nov 26, 2024
8 checks passed
@LilithHafner LilithHafner deleted the lh/sort-default branch November 26, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sorting Put things in order

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants