Skip to content

Commit c4c54b9

Browse files
PraneethJainbarche
authored andcommitted
feat: StdListSort
1 parent 7453ef8 commit c4c54b9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/StdLib/StdList.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Base.push!(v::StdList, x) = (list_push_back!(v, x); v)
1010
Base.pushfirst!(v::StdList, x) = (list_push_front!(v, x); v)
1111
Base.pop!(v::StdList) = (list_pop_back!(v); v)
1212
Base.popfirst!(v::StdList) = (list_pop_front!(v); v)
13-
13+
Base.sort!(v::StdList) = (StdListSort(v); v)
1414

1515
Base.:(==)(a::StdListIterator, b::StdListIterator) = iterator_is_equal(a, b)
1616
_list_iteration_tuple(v::StdList, state::StdListIterator) = (state == iteratorend(v)) ? nothing : (iterator_value(state), state)

test/stdlib.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,19 @@ end
664664
end
665665
end
666666
end
667+
668+
@testset "StdListSort" begin
669+
list = StdList{Int64}()
670+
v = [1, -1, 0, 4, 20]
671+
for x in v
672+
push!(list, x)
673+
end
674+
v = sort!(v)
675+
list = sort!(list)
676+
for (a, b) in zip(list, v)
677+
@test a == b
678+
end
679+
end
667680
end
668681

669682
end

0 commit comments

Comments
 (0)