From ae6e841e46de4df7f27a8f26d07471a09166c89d Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 21 Mar 2024 18:02:03 +0100 Subject: [PATCH 1/5] add docstring for SMALL_ALGORITHM --- base/sort.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/sort.jl b/base/sort.jl index eb57da376f4ab..23b2f595c3ac3 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -811,6 +811,14 @@ Characteristics: * *quadratic performance* in the number of elements to be sorted: it is well-suited to small collections but should not be used for large ones. """ + + +""" + SMALL_ALGORITHM + +Alias for Insertion sort algorithm ,witch is used for sorting small arreys. + +""" const InsertionSort = InsertionSortAlg() const SMALL_ALGORITHM = InsertionSortAlg() From 3372ce60092596c1035f2f6ab7e7807d86911353 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 21 Mar 2024 20:48:47 +0100 Subject: [PATCH 2/5] rework --- base/sort.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sort.jl b/base/sort.jl index 23b2f595c3ac3..2ac8766679409 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -816,7 +816,7 @@ it is well-suited to small collections but should not be used for large ones. """ SMALL_ALGORITHM -Alias for Insertion sort algorithm ,witch is used for sorting small arreys. +Default algorithm for small arreys """ const InsertionSort = InsertionSortAlg() From fdc671e9afd902c8d4b0efedc3a4c5f15beb0679 Mon Sep 17 00:00:00 2001 From: danik292 <116908854+danik292@users.noreply.github.com> Date: Thu, 21 Mar 2024 21:06:16 +0100 Subject: [PATCH 3/5] move docstring Co-authored-by: Lilith Orion Hafner --- base/sort.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/base/sort.jl b/base/sort.jl index 2ac8766679409..0ba8bb89d3dc2 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -811,15 +811,13 @@ Characteristics: * *quadratic performance* in the number of elements to be sorted: it is well-suited to small collections but should not be used for large ones. """ - +const InsertionSort = InsertionSortAlg() """ SMALL_ALGORITHM -Default algorithm for small arreys - +Default algorithm for small arrays """ -const InsertionSort = InsertionSortAlg() const SMALL_ALGORITHM = InsertionSortAlg() function _sort!(v::AbstractVector, ::InsertionSortAlg, o::Ordering, kw) From 69020ca25a096c6ca63f9943e882e3c786ededae Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Thu, 21 Mar 2024 15:09:12 -0500 Subject: [PATCH 4/5] change tests to reflect the fact that SMALL_ALGORITHM is no longer undocumented --- test/sorting.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sorting.jl b/test/sorting.jl index d1875c9727a29..2714197f58823 100644 --- a/test/sorting.jl +++ b/test/sorting.jl @@ -12,7 +12,7 @@ using .Main.OffsetArrays @testset "Base.Sort docstrings" begin undoc = Docs.undocumented_names(Base.Sort) @test_broken isempty(undoc) - @test undoc == [:Algorithm, :SMALL_ALGORITHM, :SMALL_THRESHOLD, :Sort] + @test undoc == [:Algorithm, :SMALL_THRESHOLD, :Sort] end @testset "Order" begin From a765bcc9d26b3f6767920ef407a55bb8feac62a6 Mon Sep 17 00:00:00 2001 From: danik292 <116908854+danik292@users.noreply.github.com> Date: Fri, 22 Mar 2024 15:48:49 +0100 Subject: [PATCH 5/5] Add details Co-authored-by: Steven G. Johnson --- base/sort.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base/sort.jl b/base/sort.jl index 0ba8bb89d3dc2..281a75cac309e 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -816,7 +816,11 @@ const InsertionSort = InsertionSortAlg() """ SMALL_ALGORITHM -Default algorithm for small arrays +Default sorting algorithm for small arrays. + +This is an alias for a simple low-overhead algorithm that does not scale well +to large arrays, unlike high-overhead recursive algorithms used for larger arrays. +`SMALL_ALGORITHM` is a good choice for the base case of a recursive algorithm. """ const SMALL_ALGORITHM = InsertionSortAlg()