Skip to content

Commit 7eb9615

Browse files
authored
Fix sorting missing values with offset indices (#48864)
* Fix sorting missing values with offset indices * Add tests
1 parent 0f7b419 commit 7eb9615

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

base/sort.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ Base.@propagate_inbounds function Base.setindex!(v::WithoutMissingVector, x, i)
533533
v
534534
end
535535
Base.size(v::WithoutMissingVector) = size(v.data)
536+
Base.axes(v::WithoutMissingVector) = axes(v.data)
536537

537538
"""
538539
send_to_end!(f::Function, v::AbstractVector; [lo, hi])

test/sorting.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,13 @@ end
562562
end
563563
end
564564

565+
@testset "Offset with missing (#48862)" begin
566+
v = [-1.0, missing, 1.0, 0.0, missing, -0.5, 0.5, 1.0, -0.5, missing, 0.5, -0.8, 1.5, NaN]
567+
vo = OffsetArray(v, (firstindex(v):lastindex(v)).+100)
568+
@test issorted(sort!(vo))
569+
@test issorted(v)
570+
end
571+
565572
@testset "searchsortedfirst/last with generalized indexing" begin
566573
o = OffsetVector(1:3, -2)
567574
@test searchsortedfirst(o, 4) == lastindex(o) + 1

0 commit comments

Comments
 (0)