Skip to content

BoundsError in sort! on ill-behaved user-specified comparisons #11429

Closed

Description

The following reduced example triggers a BoundsError in both 0.3.8 and latest master:

a = rand(1:5, 2, 1000)
ind = collect(1:size(a,2))
sort!(ind, lt = (x,y) -> a[1,x]<=a[1,y])
ERROR: LoadError: BoundsError: attempt to access 2x1000 Array{Int64,2}:
 2  5  5  3  5  2  2  5  5  3  4  3  2    3  1  1  2  5  4  1  4  5  1  4  3
 2  4  2  5  4  4  2  2  3  5  4  5  5     3  3  2  4  5  5  2  1  1  5  4  2
  at index [1,140649597000272]
 in getindex at array.jl:299
 in anonymous at /Users/rene/BTSync/code/git/sortrows/test.jl:3
 in sort! at sort.jl:297
 in sort! at sort.jl:306
 in sort! at sort.jl:359
 in include at ./boot.jl:252
 in include_from_node1 at loading.jl:133
 in process_options at ./client.jl:310
 in _start at ./client.jl:409
while loading /Users/rene/BTSync/code/git/sortrows/test.jl, in expression starting on line 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]bugIndicates an unexpected problem or unintended behaviorsortingPut things in order

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions