Skip to content

Commit

Permalink
Sorting across different datatypes (#17)
Browse files Browse the repository at this point in the history
* Update TupleTools.jl

* Update runtests.jl

* fix
  • Loading branch information
putianyi889 authored Sep 13, 2023
1 parent 0b1147f commit 8e9d0c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/TupleTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ end
_sort(t::Tuple{Any}, lt=isless, by=identity, rev::Bool=false) = t
_sort(t::Tuple{}, lt=isless, by=identity, rev::Bool=false) = t

function _split(t::NTuple{N}) where N
function _split(t::Tuple)
N = length(t)
M = N>>1
ntuple(i->t[i], M), ntuple(i->t[i+M], N-M)
end
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ end
@test @inferred(TupleTools.diff(())) == ()
@test @inferred(TupleTools.diff((1, ))) == ()
@test @inferred(TupleTools.diff((1, 2, 3))) == (1, 1)

@test TupleTools.sort((2,1,3.0)) === (1,2,3.0)

0 comments on commit 8e9d0c4

Please sign in to comment.