Skip to content

sortperm errors with length of vector less than 4 and if dims=1. #55370

@roflmaostc

Description

Hi,

failing on 1.10 and a recent master branch:

julia> sortperm([1,1,1,1], dims=1)
4-element Vector{Int64}:
 1
 2
 3
 4

julia> sortperm([1,1,1], dims=1)
ERROR: MethodError: no method matching sort!(::Vector{…}; alg::Base.Sort.SubArrayOptimization{…}, order::Base.Order.Perm{…}, scratch::Nothing, dims::Int64)
This method does not support all of the given keyword arguments (and may not support any).

Closest candidates are:
  sort!(::AbstractVector{T}, ::Integer, ::Integer, ::Base.Sort.MergeSortAlg, ::Base.Order.Ordering, ::Vector{T}) where T got unsupported keyword arguments "alg", "order", "scratch", "dims"
   @ Base sort.jl:2391
  sort!(::AbstractVector{T}, ::Integer, ::Integer, ::Base.Sort.MergeSortAlg, ::Base.Order.Ordering, ::Union{Nothing, AbstractVector{T}}) where T got unsupported keyword arguments "alg", "order", "scratch", "dims"
   @ Base sort.jl:2393
  sort!(::AbstractVector, ::Integer, ::Integer, ::Base.Sort.Algorithm, ::Base.Order.Ordering, ::Vector) got unsupported keyword arguments "alg", "order", "scratch", "dims"
   @ Base sort.jl:2470
  ...

Stacktrace:
 [1] kwerr(::@NamedTuple{}, ::Function, ::Vector{…})
   @ Base ./error.jl:174
 [2] _sortperm(A::Vector{…}; alg::Base.Sort.SubArrayOptimization{…}, order::Base.Order.ForwardOrdering, scratch::Nothing, dims::@Kwargs{})
   @ Base.Sort ./sort.jl:1912
 [3] _sortperm
   @ ./sort.jl:1899 [inlined]
 [4] #sortperm#36
   @ ./sort.jl:1896 [inlined]
 [5] top-level scope
   @ REPL[2]:1
Some type information was truncated. Use `show(err)` to see complete types.

We might have a sensible solution to this. We do the PR later.

Best,

Felix

cc: @sepehr78

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorsortingPut things in order

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions