Skip to content

Commit

Permalink
docs: fix example for sort and add new doctest (#56843)
Browse files Browse the repository at this point in the history
  • Loading branch information
rapus95 authored Dec 18, 2024
1 parent e5b946c commit b1007ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1700,13 +1700,16 @@ julia> v = [(1, "c"), (3, "a"), (2, "b")]; sort!(v, by = x -> x[2]); v
(2, "b")
(1, "c")
julia> sort(0:3, by=x->x-2, order=Base.Order.By(abs)) # same as sort(0:3, by=abs(x->x-2))
julia> sort(0:3, by=x->x-2, order=Base.Order.By(abs))
4-element Vector{Int64}:
2
1
3
0
julia> sort(0:3, by=x->x-2, order=Base.Order.By(abs)) == sort(0:3, by=x->abs(x-2))
true
julia> sort([2, NaN, 1, NaN, 3]) # correct sort with default lt=isless
5-element Vector{Float64}:
1.0
Expand Down

0 comments on commit b1007ce

Please sign in to comment.