Skip to content
Open
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: 2 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3016,6 +3016,8 @@ function isequal(A::AbstractArray, B::AbstractArray)
end

function cmp(A::AbstractVector, B::AbstractVector)
ai1, bi1 = firstindex(A), firstindex(B)
isequal(ai1, bi1) || return cmp(ai1, bi1)
for (a, b) in zip(A, B)
if !isequal(a, b)
return isless(a, b) ? -1 : 1
Expand Down
12 changes: 12 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,18 @@ end
@test cmp([UInt8(1), UInt8(0)], [UInt8(0), UInt8(0)]) == 1
@test cmp([UInt8(1), UInt8(0)], [UInt8(1), UInt8(0)]) == 0
@test cmp([UInt8(0), UInt8(0)], [UInt8(1), UInt8(1)]) == -1

x = [1, 2, 3]
y = OffsetVector(x, -1)
@test cmp(x, y) == 1
@test cmp(y, x) == -1
@test !isless(x, y)
@test isless(y, x)

y2 = OffsetVector([1, 2, 3], 0)
@test cmp(x, y2) == 0
@test !isless(x, y2)
@test !isless(y2, x)
end

@testset "sort on arrays" begin
Expand Down