-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to stable sorting algorithm #47309
Switch to stable sorting algorithm #47309
Conversation
I guess, we can deprecate |
Unfortunately, folks outside of Base are still using # DataFrames.jl
Sort.defalg(df::AbstractDataFrame) =
size(df, 1) < 8192 ? Sort.MergeSort : SortingAlgorithms.TimSort
# InlineStrings.jl
Base.Sort.defalg(::AbstractArray{<:Union{SmallInlineStrings, Missing}}) = InlineStringSort
# StaticArrays.jl
defalg(a::StaticVector) =
isimmutable(a) && length(a) <= 20 ? BitonicSort : QuickSort
# Catalyst.jl
Base.Sort.defalg(::ReactionComplex) = Base.DEFAULT_UNSTABLE Eventually, it may be possible to remove & replace |
to be fair, you could probably remove those uses. Between the stable quicksort and radix sort that you've added, I doubt that any of these are still optimal heuristics. |
It makes some sense to allow user to select the default sorting algorithm for user-defined types. Thus, I'll revert changes replacint The only remaining question is why Line 1244 in 7cbf55f
|
Mergesort creates a temporary array with size Multidimensional arrays should use This is making me think that perhaps function sortperm(A::AbstractArray;
alg=nothing,
lt=isless,
by=identity,
rev::Union{Bool,Nothing}=nothing,
order::Ordering=Forward,
buffer::Union{AbstractVector{<:Integer}, Nothing}=nothing,
dims...)
ordr = ord(lt,by,rev,order)
_alg::Algorithm = alg === nothing ? defalg(sortperm, A, ordr; buffer, dims...) : alg
... |
@LilithHafner If you agree on that changes, you can merge this into your branch now ... and we can polish it there if necessary. |
@LilithHafner Since you changed the docs to guarantee the stability, I propose to switch to
DEFAULT_STABLE
(by removing other cases) in the same PR #47303.Warning: This PR is against your branch, not master.