Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,7 @@ function sort!(A::AbstractArray{T};
by=identity,
rev::Union{Bool,Nothing}=nothing,
order::Ordering=Forward, # TODO stop eagerly over-allocating.
scratch::Union{Vector{T}, Nothing}=similar(A, size(A, dims))) where T
scratch::Union{Vector{T}, Nothing}=Vector{T}(undef, size(A, dims))) where T
__sort!(A, Val(dims), maybe_apply_initial_optimizations(alg), ord(lt, by, rev, order), scratch)
end
function __sort!(A::AbstractArray{T}, ::Val{K},
Expand Down
14 changes: 14 additions & 0 deletions test/sorting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,20 @@ end
end
end

struct MyArray49392{T, N} <: AbstractArray{T, N}
data::Array{T, N}
end
Base.size(A::MyArray49392) = size(A.data)
Base.getindex(A::MyArray49392, i...) = getindex(A.data, i...)
Base.setindex!(A::MyArray49392, v, i...) = setindex!(A.data, v, i...)
Base.similar(A::MyArray49392, ::Type{T}, dims::Dims{N}) where {T, N} = MyArray49392(similar(A.data, T, dims))

@testset "Custom matrices (#49392)" begin
x = rand(10, 10)
y = MyArray49392(copy(x))
@test all(sort!(y, dims=2) .== sort!(x,dims=2))
end

# This testset is at the end of the file because it is slow.
@testset "searchsorted" begin
numTypes = [ Int8, Int16, Int32, Int64, Int128,
Expand Down