Skip to content

Commit 165e032

Browse files
committed
Revert "sort for NTuple and other iterables (#804)"
This reverts commit c59d116.
1 parent db2077e commit 165e032

File tree

4 files changed

+1
-73
lines changed

4 files changed

+1
-73
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Compat"
22
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
3-
version = "4.10.0"
3+
version = "4.10.1"
44

55
[deps]
66
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ changes in `julia`.
7272

7373
* `@compat public foo, bar` marks `foo` and `bar` as public in Julia 1.11+ and is a no-op in Julia 1.10 and earlier. ([#50105]) (since Compat 4.10.0)
7474

75-
* `sort` for `NTuple` and other iterables. ([#46104]) (since Compat 4.9.0)
76-
7775
* `redirect_stdio`, for simple stream redirection. ([#37978]) (since Compat 4.8.0)
7876

7977
* `trunc`, `floor`, `ceil`, and `round` to `Bool`. ([#25085]) (since Compat 4.7.0)
@@ -172,6 +170,5 @@ Note that you should specify the correct minimum version for `Compat` in the
172170
[#43334]: https://github.com/JuliaLang/julia/issues/43334
173171
[#43354]: https://github.com/JuliaLang/julia/issues/43354
174172
[#43852]: https://github.com/JuliaLang/julia/issues/43852
175-
[#46104]: https://github.com/JuliaLang/julia/issues/46104
176173
[#48038]: https://github.com/JuliaLang/julia/issues/48038
177174
[#50105]: https://github.com/JuliaLang/julia/issues/50105

src/Compat.jl

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -705,42 +705,6 @@ if VERSION < v"1.7.0-DEV.1187"
705705
export redirect_stdio
706706
end
707707

708-
# https://github.com/JuliaLang/julia/pull/46104
709-
if VERSION < v"1.10.0-DEV.1404"
710-
using Base: Ordering, Forward, ord, lt, tail, copymutable, DEFAULT_STABLE, IteratorSize, HasShape, IsInfinite
711-
function Base.sort(v; kws...)
712-
size = IteratorSize(v)
713-
size == HasShape{0}() && throw(ArgumentError("$v cannot be sorted"))
714-
size == IsInfinite() && throw(ArgumentError("infinite iterator $v cannot be sorted"))
715-
sort!(copymutable(v); kws...)
716-
end
717-
Base.sort(::AbstractString; kws...) =
718-
throw(ArgumentError("sort(::AbstractString) is not supported"))
719-
Base.sort(::Tuple; kws...) =
720-
throw(ArgumentError("sort(::Tuple) is only supported for NTuples"))
721-
722-
function Base.sort(x::NTuple{N}; lt::Function=isless, by::Function=identity,
723-
rev::Union{Bool,Nothing}=nothing, order::Ordering=Forward) where N
724-
o = ord(lt,by,rev,order)
725-
if N > 9
726-
v = sort!(copymutable(x), DEFAULT_STABLE, o)
727-
tuple((v[i] for i in 1:N)...)
728-
else
729-
_sort(x, o)
730-
end
731-
end
732-
_sort(x::Union{NTuple{0}, NTuple{1}}, o::Ordering) = x
733-
function _sort(x::NTuple, o::Ordering)
734-
a, b = Base.IteratorsMD.split(x, Val(length(x)>>1))
735-
merge(_sort(a, o), _sort(b, o), o)
736-
end
737-
merge(x::NTuple, y::NTuple{0}, o::Ordering) = x
738-
merge(x::NTuple{0}, y::NTuple, o::Ordering) = y
739-
merge(x::NTuple{0}, y::NTuple{0}, o::Ordering) = x # Method ambiguity
740-
merge(x::NTuple, y::NTuple, o::Ordering) =
741-
(lt(o, y[1], x[1]) ? (y[1], merge(x, tail(y), o)...) : (x[1], merge(tail(x), y, o)...))
742-
end
743-
744708
include("deprecated.jl")
745709

746710
end # module Compat

test/runtests.jl

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -692,39 +692,6 @@ end
692692
end
693693
end
694694

695-
# https://github.com/JuliaLang/julia/pull/46104
696-
@testset "sort(iterable)" begin
697-
function tuple_sort_test(x)
698-
@test issorted(sort(x))
699-
length(x) > 9 && return # length > 9 uses a vector fallback
700-
@test 0 == @allocated sort(x)
701-
end
702-
@testset "sort(::NTuple)" begin
703-
@test sort((9,8,3,3,6,2,0,8)) == (0,2,3,3,6,8,8,9)
704-
@test sort((9,8,3,3,6,2,0,8), by=x->x÷3) == (2,0,3,3,8,6,8,9)
705-
for i in 1:40
706-
tuple_sort_test(tuple(rand(i)...))
707-
end
708-
@test_throws ArgumentError sort((1,2,3.0))
709-
end
710-
@testset "sort!(iterable)" begin
711-
gen = (x % 7 + 0.1x for x in 1:50)
712-
@test sort(gen) == sort!(collect(gen))
713-
gen = (x % 7 + 0.1y for x in 1:10, y in 1:5)
714-
@test sort(gen; dims=1) == sort!(collect(gen); dims=1)
715-
@test sort(gen; dims=2) == sort!(collect(gen); dims=2)
716-
717-
@test_throws ArgumentError("dimension out of range") sort(gen; dims=3)
718-
719-
@test_throws UndefKeywordError(:dims) sort(gen)
720-
@test_throws UndefKeywordError(:dims) sort(collect(gen))
721-
@test_throws UndefKeywordError(:dims) sort!(collect(gen))
722-
723-
@test_throws ArgumentError sort("string")
724-
@test_throws ArgumentError("1 cannot be sorted") sort(1)
725-
end
726-
end
727-
728695
module Mod50105
729696
using Compat
730697
@compat public foo, var"#", baz

0 commit comments

Comments
 (0)