diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index b3556e7..6597a6d 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-26T12:49:54","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-28T12:53:11","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/benchmark/1717c9ab.svg b/dev/benchmark/1717c9ab.svg new file mode 100644 index 0000000..073bdc0 --- /dev/null +++ b/dev/benchmark/1717c9ab.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/benchmark/b2083a7f.svg b/dev/benchmark/6262d1b8.svg similarity index 83% rename from dev/benchmark/b2083a7f.svg rename to dev/benchmark/6262d1b8.svg index e4618a4..035c180 100644 --- a/dev/benchmark/b2083a7f.svg +++ b/dev/benchmark/6262d1b8.svg @@ -30,16 +30,16 @@ - - - + + + - - - - - - + + + + + + diff --git a/dev/benchmark/b1ea878f.svg b/dev/benchmark/a8477f34.svg similarity index 89% rename from dev/benchmark/b1ea878f.svg rename to dev/benchmark/a8477f34.svg index 73e75ad..0c101c9 100644 --- a/dev/benchmark/b1ea878f.svg +++ b/dev/benchmark/a8477f34.svg @@ -62,13 +62,13 @@ - - + + - - - - + + + + diff --git a/dev/benchmark/d8b6964e.svg b/dev/benchmark/c371f2b9.svg similarity index 77% rename from dev/benchmark/d8b6964e.svg rename to dev/benchmark/c371f2b9.svg index bd53018..b566db5 100644 --- a/dev/benchmark/d8b6964e.svg +++ b/dev/benchmark/c371f2b9.svg @@ -62,19 +62,19 @@ - - - - - + + + + + - - - - - - - + + + + + + + diff --git a/dev/benchmark/f8d2cd94.svg b/dev/benchmark/f8d2cd94.svg deleted file mode 100644 index d0cb6d9..0000000 --- a/dev/benchmark/f8d2cd94.svg +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev/benchmark/index.html b/dev/benchmark/index.html index caae419..32c96c5 100644 --- a/dev/benchmark/index.html +++ b/dev/benchmark/index.html @@ -5,43 +5,43 @@ Official https://julialang.org/ release Platform Info: OS: Linux (x86_64-linux-gnu) - CPU: 2 × Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz + CPU: 4 × AMD EPYC 7763 64-Core Processor WORD_SIZE: 64 LIBM: libopenlibm - LLVM: libLLVM-15.0.7 (ORCJIT, skylake-avx512) -Threads: 1 default, 0 interactive, 1 GC (on 2 virtual cores)
julia> Pkg.status()Status `~/work/SwapSort.jl/SwapSort.jl/docs/Project.toml` - [6e4b80f9] BenchmarkTools v1.4.0 + LLVM: libLLVM-15.0.7 (ORCJIT, znver3) +Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)
julia> Pkg.status()Status `~/work/SwapSort.jl/SwapSort.jl/docs/Project.toml` + [6e4b80f9] BenchmarkTools v1.5.0 [e30172f5] Documenter v1.2.1 [b964fa9f] LaTeXStrings v1.3.1 [91a5bcdd] Plots v1.40.1 [90137ffa] StaticArrays v1.9.3 [518c31a9] SwapSort v1.0.0-DEV `~/work/SwapSort.jl/SwapSort.jl` - [9a3f8284] Random

Package loading

The precompilation is very slow since the package reads many json files and build sorting methods based on them.

julia> @time Pkg.precompile("SwapSort")  2.503307 seconds (1.10 M allocations: 77.507 MiB, 5.61% gc time, 93.23% compilation time)
julia> @time using SwapSort 0.000181 seconds (153 allocations: 14.469 KiB)

Same type (type-stable)

When sorting variables of the same type, swapsort has longer compilation time but from 5x to 100x runtime depending on the sorting size. To save the build time of the doc, this page only contains a simplified benchmark. For the full benchmark, run the script.

using SwapSort, StaticArrays, Plots, BenchmarkTools
+  [9a3f8284] Random

Package loading

The precompilation is very slow since the package reads many json files and build sorting methods based on them.

julia> @time Pkg.precompile("SwapSort")  1.582212 seconds (1.10 M allocations: 77.521 MiB, 4.66% gc time, 94.07% compilation time)
julia> @time using SwapSort 0.000117 seconds (153 allocations: 14.469 KiB)

Same type (type-stable)

When sorting variables of the same type, swapsort has longer compilation time but from 5x to 100x runtime depending on the sorting size. To save the build time of the doc, this page only contains a simplified benchmark. For the full benchmark, run the script.

using SwapSort, StaticArrays, Plots, BenchmarkTools
 samples = [1,2,4,8,16,32,64]
 swapsorttime = zeros(7)
 svectortime = zeros(7)
 vectortime = zeros(7)
 a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De = rand(64)
64-element Vector{Float64}:
- 0.03690513357923075
- 0.10314538678300744
- 0.20981943988026353
- 0.4170343522069384
- 0.8340315188923318
- 0.05567614645351493
- 0.6666981417583379
- 0.24398298625649517
- 0.29643884902928475
- 0.36335673043290106
+ 0.13149337274461181
+ 0.15022822903065514
+ 0.3466555255310896
+ 0.8254747126978271
+ 0.7868499772461707
+ 0.3884835620347813
+ 0.7125606921940892
+ 0.6682370732651164
+ 0.12437102833521319
+ 0.7742889216772635
  ⋮
- 0.5790339512248562
- 0.8019549336426676
- 0.5118299985002054
- 0.2857914765173615
- 0.729339285107616
- 0.44594646311695463
- 0.32269515497383083
- 0.4717320647511978
- 0.46897420853064753

Compilation

swapsorttime[1] = @elapsed swapsort(a)
+ 0.09302758238028641
+ 0.8464347451961607
+ 0.9868445896010382
+ 0.6127381539228343
+ 0.7197211104196284
+ 0.6976228510074353
+ 0.8505858960160484
+ 0.14675642095731445
+ 0.05677050480992418

Compilation

swapsorttime[1] = @elapsed swapsort(a)
 swapsorttime[2] = @elapsed swapsort(a,b)
 swapsorttime[3] = @elapsed swapsort(a,b,c,d)
 swapsorttime[4] = @elapsed swapsort(a,b,c,d,e,f,g,h)
@@ -55,8 +55,8 @@
 vectortime[1] = @elapsed sort!([a])
 #= Do the same thing. Lines are hidden=#
 
-plot(samples, [swapsorttime svectortime vectortime], labels=["swapsort" "SVector" "Vector"])
Example block output

Runtime

Replacing @elapsed with @belapsed, we get the runtime.

plot(samples, [swapsorttime svectortime vectortime], labels=["swapsort" "SVector" "Vector"])
Example block output

Different types (type-unstable)

When sorting across different types, methods based on Tuple or Vararg suffer from type inference as different orders have different types. As a result, the compilation time can be a lot longer. In this benchmark, we consider up to 23 variables of different types, including

  • 7 Number types: Int, Float, Irrational, Complex, Rational, BigInt, BigFloat
  • 8 Collection types: Tuple, Set, Dict, Matrix, Vector, String, Range, NamedTuple
  • 8 Other types: CartesianIndex, Pair, Function, Symbol, Type, Module, Nothing, Char
using Random, SwapSort, Plots, BenchmarkTools, StaticArrays
+plot(samples, [swapsorttime svectortime vectortime], labels=["swapsort" "SVector" "Vector"])
Example block output

Runtime

Replacing @elapsed with @belapsed, we get the runtime.

plot(samples, [swapsorttime svectortime vectortime], labels=["swapsort" "SVector" "Vector"])
Example block output

Different types (type-unstable)

When sorting across different types, methods based on Tuple or Vararg suffer from type inference as different orders have different types. As a result, the compilation time can be a lot longer. In this benchmark, we consider up to 23 variables of different types, including

  • 7 Number types: Int, Float, Irrational, Complex, Rational, BigInt, BigFloat
  • 8 Collection types: Tuple, Set, Dict, Matrix, Vector, String, Range, NamedTuple
  • 8 Other types: CartesianIndex, Pair, Function, Symbol, Type, Module, Nothing, Char
using Random, SwapSort, Plots, BenchmarkTools, StaticArrays
 a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w = shuffle(
     [rand(Int), rand(), π, im, 1//2, BigInt(rand(Int128)), rand(BigFloat),
     (1,2), Set([1,2]), Dict(1=>2), rand(2,2), rand(Int, 10), randstring(), 1:10, (a=1,b=2),
-    CartesianIndex(1,2), 1=>2, sin, :sin, typeof(sin), SwapSort, nothing, 'a'])

Compilation

Example block output

Runtime

Example block output + CartesianIndex(1,2), 1=>2, sin, :sin, typeof(sin), SwapSort, nothing, 'a'])

Compilation

Example block output

Runtime

Example block output diff --git a/dev/docstrings/index.html b/dev/docstrings/index.html index 9c36ac9..3d2d000 100644 --- a/dev/docstrings/index.html +++ b/dev/docstrings/index.html @@ -1,2 +1,2 @@ -Docstrings · SwapSort

Docstrings

SwapSort.min_maxMethod
min_max(x, y; lt=isless, by=identity) = lt(by(x), by(y)) ? (x,y) : (y,x)

The same as Base.minmax, but supports lt and by keywords which works as those in Base.sort.

source
SwapSort.swapsortMethod
swapsort(a...; lt=isless, by=identity)

Sort the arguments, returning a sorted tuple. lt and by keywords work the same as Base.sort. swapsort supports up to 64 arguments. See also tuplesort.

source
SwapSort.tuplesortFunction
tuplesort(t::Tuple; lt=isless, by=identity)

Return a sorted tuple. lt and by keywords work the same as Base.sort. tuplesort calls swapsort and supports at most 64 elements.

source
+Docstrings · SwapSort

Docstrings

SwapSort.min_maxMethod
min_max(x, y; lt=isless, by=identity) = lt(by(x), by(y)) ? (x,y) : (y,x)

The same as Base.minmax, but supports lt and by keywords which works as those in Base.sort.

source
SwapSort.swapsortMethod
swapsort(a...; lt=isless, by=identity)

Sort the arguments, returning a sorted tuple. lt and by keywords work the same as Base.sort. swapsort supports up to 64 arguments. See also tuplesort.

source
SwapSort.tuplesortMethod
tuplesort(t::Tuple; lt=isless, by=identity)

Return a sorted tuple. lt and by keywords work the same as Base.sort. tuplesort calls swapsort and supports at most 64 elements.

source
diff --git a/dev/index.html b/dev/index.html index d8b860e..190a16a 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -SwapSort.jl · SwapSort

SwapSort.jl

This package is intended to be a successor of SortingNetworks.jl. This package relies on the existing sorters which are currently copied from SorterHunter, a C++ project. For a visualization of the algorithms, see here.

  • PROS
    • Supports lt and by keywords.
    • Easier to to add new algorithms as all codes are generated.
    • Supports sorting across different types. Note that type stability will become a problem in this case.
  • CONS
    • Very long precompilation (~55s on my machine). The current bottleneck is JSON.parsefile. The importing is fine (~30ms).
    • Harder to troubleshoot since the most important things are written in macros.
    • Does not support sorting a vector. The reason is that Base.sort is efficient enough for a vector.
    • Does not support sorting a tuple at present.

Internals

There are many internal functions in the form of swapsortN_L_D(::Vararg{Any,N}). N refers to the data size, L refers to the number of comparisons/swaps. Although currently unsupported, it's possible to execute some swaps in parallel and D refers to the number of steps when computing in parallel. All available (N,L,D) triples are listed at SwapSort.SORTERS.

julia> show(SwapSort.SORTERS)ERROR: UndefVarError: `SwapSort` not defined

The exported swapsort at present chooses the least available L for each N. For example, swapsort(a,b) = swapsort2_1_1(a,b). The choices are listed at SwapSort.BESTSIZE.

julia> show(SwapSort.BESTSIZE)ERROR: UndefVarError: `SwapSort` not defined

The exported tuplesort is just another wrapper. It uses a different name as swapsort because otherwise it would be ambiguous whether the tuple is considered as one element or a group of elements. We note that TupleTools.jl uses merge sort on tuples.

Performance

The sorting algorithm is called sorting network. It's not the most efficient algorithm for general purpose, but in Julia, it excels at sorting a few discrete variables, as collecting/splatting is very slow.

StaticArrays.jl implements BitonicSort which is a special case of sorting network. It is more flexible, but has two drawbacks:

  • The import time of StaticArrays is 10x slower than SwapSort.
  • Sorting a few variables needs to pack them into a static vector. The packing in Julia is slow.
+SwapSort.jl · SwapSort

SwapSort.jl

This package is intended to be a successor of SortingNetworks.jl. This package relies on the existing sorters which are currently copied from SorterHunter, a C++ project. For a visualization of the algorithms, see here.

  • PROS
    • Supports lt and by keywords.
    • Easier to to add new algorithms as all codes are generated.
    • Supports sorting across different types. Note that type stability will become a problem in this case.
  • CONS
    • Very long precompilation (~30s on CI). The current bottleneck is JSON.parsefile. The compilation is ok and the importing is fast.
    • Harder to troubleshoot since the most important things are written in macros.
    • Does not support sorting a vector. The reason is that Base.sort is efficient enough for a vector.
    • Does not support sorting a tuple at present.

Internals

There are many internal functions in the form of swapsortN_L_D(::Vararg{Any,N}). N refers to the data size, L refers to the number of comparisons/swaps. Although currently unsupported, it's possible to execute some swaps in parallel and D refers to the number of steps when computing in parallel. All available (N,L,D) triples are listed at SwapSort.SORTERS.

julia> show(SwapSort.SORTERS)ERROR: UndefVarError: `SwapSort` not defined

The exported swapsort at present chooses the least available L for each N. For example, swapsort(a,b) = swapsort2_1_1(a,b). The choices are listed at SwapSort.BESTSIZE.

julia> show(SwapSort.BESTSIZE)ERROR: UndefVarError: `SwapSort` not defined

The exported tuplesort is just another wrapper. It uses a different name as swapsort because otherwise it would be ambiguous whether the tuple is considered as one element or a group of elements. We note that TupleTools.jl uses merge sort on tuples.

Performance

The sorting algorithm is called sorting network. It's not the most efficient algorithm for general purpose, but in Julia, it excels at sorting a few discrete variables, as collecting/splatting is very slow.

StaticArrays.jl implements BitonicSort which is a special case of sorting network. It is more flexible, but has two drawbacks:

  • The import time of StaticArrays is 10x slower than SwapSort.
  • Sorting a few variables needs to pack them into a static vector. The packing in Julia is slow.
diff --git a/dev/search_index.js b/dev/search_index.js index 57568c9..208a85e 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"benchmark/#Benchmarks","page":"Benchmarks","title":"Benchmarks","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"The benchmarks are generated by the GitHub Actions. ","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"using InteractiveUtils, Pkg","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"versioninfo()\nPkg.status()","category":"page"},{"location":"benchmark/#Package-loading","page":"Benchmarks","title":"Package loading","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"The precompilation is very slow since the package reads many json files and build sorting methods based on them.","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"@time Pkg.precompile(\"SwapSort\")\n@time using SwapSort","category":"page"},{"location":"benchmark/#Same-type-(type-stable)","page":"Benchmarks","title":"Same type (type-stable)","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"When sorting variables of the same type, swapsort has longer compilation time but from 5x to 100x runtime depending on the sorting size. To save the build time of the doc, this page only contains a simplified benchmark. For the full benchmark, run the script.","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"using SwapSort, StaticArrays, Plots, BenchmarkTools\nusing LaTeXStrings # hide\nBenchmarkTools.DEFAULT_PARAMETERS.seconds = 0.5 # hide\nsamples = [1,2,4,8,16,32,64]\nswapsorttime = zeros(7)\nsvectortime = zeros(7)\nvectortime = zeros(7)\ndefault(background_color=:transparent, foreground_color=:gray, yaxis=:log, xaxis=:log2, xticks=(samples, [L\"2^0\", L\"2^1\", L\"2^2\", L\"2^3\", L\"2^4\", L\"2^5\", L\"2^6\"])) # hide\na,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De = rand(64)","category":"page"},{"location":"benchmark/#Compilation","page":"Benchmarks","title":"Compilation","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"swapsorttime[1] = @elapsed swapsort(a)\nswapsorttime[2] = @elapsed swapsort(a,b)\nswapsorttime[3] = @elapsed swapsort(a,b,c,d)\nswapsorttime[4] = @elapsed swapsort(a,b,c,d,e,f,g,h)\nswapsorttime[5] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)\nswapsorttime[6] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F)\nswapsorttime[7] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De)\n\nsvectortime[1] = @elapsed sort(SVector(a))\n#= Do the same thing. Lines are hidden=#\nsvectortime[2] = @elapsed sort(SVector(a,b)) # hide\nsvectortime[3] = @elapsed sort(SVector(a,b,c,d)) # hide\nsvectortime[4] = @elapsed sort(SVector(a,b,c,d,e,f,g,h)) # hide\nsvectortime[5] = @elapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)) # hide\nsvectortime[6] = @elapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F)) # hide\nsvectortime[7] = @elapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De)) # hide\n\nvectortime[1] = @elapsed sort!([a])\n#= Do the same thing. Lines are hidden=#\nvectortime[2] = @elapsed sort!([a,b]) # hide\nvectortime[3] = @elapsed sort!([a,b,c,d]) # hide\nvectortime[4] = @elapsed sort!([a,b,c,d,e,f,g,h]) # hide\nvectortime[5] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p]) # hide\nvectortime[6] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F]) # hide\nvectortime[7] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De]) # hide\n\nplot(samples, [swapsorttime svectortime vectortime], labels=[\"swapsort\" \"SVector\" \"Vector\"])","category":"page"},{"location":"benchmark/#Runtime","page":"Benchmarks","title":"Runtime","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"Replacing @elapsed with @belapsed, we get the runtime.","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"swapsorttime[1] = @belapsed swapsort(a) # hide\nswapsorttime[2] = @belapsed swapsort(a,b) # hide\nswapsorttime[3] = @belapsed swapsort(a,b,c,d) # hide\nswapsorttime[4] = @belapsed swapsort(a,b,c,d,e,f,g,h) # hide\nswapsorttime[5] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) # hide\nswapsorttime[6] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F) # hide\nswapsorttime[7] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De) # hide\n\nsvectortime[1] = @belapsed sort(SVector(a)) # hide\nsvectortime[2] = @belapsed sort(SVector(a,b)) # hide\nsvectortime[3] = @belapsed sort(SVector(a,b,c,d)) # hide\nsvectortime[4] = @belapsed sort(SVector(a,b,c,d,e,f,g,h)) # hide\nsvectortime[5] = @belapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)) # hide\nsvectortime[6] = @belapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F)) # hide\nsvectortime[7] = @belapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De)) # hide\n\nvectortime[1] = @belapsed sort!([a]) # hide\nvectortime[2] = @belapsed sort!([a,b]) # hide\nvectortime[3] = @belapsed sort!([a,b,c,d]) # hide\nvectortime[4] = @belapsed sort!([a,b,c,d,e,f,g,h]) # hide\nvectortime[5] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p]) # hide\nvectortime[6] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F]) # hide\nvectortime[7] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De]) # hide\n\nplot(samples, [swapsorttime svectortime vectortime], labels=[\"swapsort\" \"SVector\" \"Vector\"])","category":"page"},{"location":"benchmark/#Different-types-(type-unstable)","page":"Benchmarks","title":"Different types (type-unstable)","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"When sorting across different types, methods based on Tuple or Vararg suffer from type inference as different orders have different types. As a result, the compilation time can be a lot longer. In this benchmark, we consider up to 23 variables of different types, including","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"7 Number types: Int, Float, Irrational, Complex, Rational, BigInt, BigFloat\n8 Collection types: Tuple, Set, Dict, Matrix, Vector, String, Range, NamedTuple\n8 Other types: CartesianIndex, Pair, Function, Symbol, Type, Module, Nothing, Char","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"using Random, SwapSort, Plots, BenchmarkTools, StaticArrays\ndefault(background_color=:transparent, foreground_color=:gray, yaxis=:log, xaxis=:identity, xticks=1:23) # hide\nBenchmarkTools.DEFAULT_PARAMETERS.seconds = 0.5 # hide\na,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w = shuffle(\n [rand(Int), rand(), π, im, 1//2, BigInt(rand(Int128)), rand(BigFloat), \n (1,2), Set([1,2]), Dict(1=>2), rand(2,2), rand(Int, 10), randstring(), 1:10, (a=1,b=2), \n CartesianIndex(1,2), 1=>2, sin, :sin, typeof(sin), SwapSort, nothing, 'a'])\nswapsorttime = zeros(23) # hide\nvectortime = zeros(23) # hide","category":"page"},{"location":"benchmark/#Compilation-2","page":"Benchmarks","title":"Compilation","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"swapsorttime[1] = @elapsed swapsort(a; by=string) # hide\nswapsorttime[2] = @elapsed swapsort(a,b; by=string) # hide\nswapsorttime[3] = @elapsed swapsort(a,b,c; by=string) # hide\nswapsorttime[4] = @elapsed swapsort(a,b,c,d; by=string) # hide\nswapsorttime[5] = @elapsed swapsort(a,b,c,d,e; by=string) # hide\nswapsorttime[6] = @elapsed swapsort(a,b,c,d,e,f; by=string) # hide\nswapsorttime[7] = @elapsed swapsort(a,b,c,d,e,f,g; by=string) # hide\nswapsorttime[8] = @elapsed swapsort(a,b,c,d,e,f,g,h; by=string) # hide\nswapsorttime[9] = @elapsed swapsort(a,b,c,d,e,f,g,h,i; by=string) # hide\nswapsorttime[10] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j; by=string) # hide\nswapsorttime[11] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k; by=string) # hide\nswapsorttime[12] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l; by=string) # hide\nswapsorttime[13] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m; by=string) # hide\nswapsorttime[14] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n; by=string) # hide\nswapsorttime[15] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o; by=string) # hide\nswapsorttime[16] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p; by=string) # hide\nswapsorttime[17] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q; by=string) # hide\nswapsorttime[18] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r; by=string) # hide\nswapsorttime[19] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s; by=string) # hide\nswapsorttime[20] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t; by=string) # hide\nswapsorttime[21] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u; by=string) # hide\nswapsorttime[22] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v; by=string) # hide\nswapsorttime[23] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w; by=string) # hide\n\nvectortime[1] = @elapsed sort!([a]; by=string) # hide\nvectortime[2] = @elapsed sort!([a,b]; by=string) # hide\nvectortime[3] = @elapsed sort!([a,b,c]; by=string) # hide\nvectortime[4] = @elapsed sort!([a,b,c,d]; by=string) # hide\nvectortime[5] = @elapsed sort!([a,b,c,d,e]; by=string) # hide\nvectortime[6] = @elapsed sort!([a,b,c,d,e,f]; by=string) # hide\nvectortime[7] = @elapsed sort!([a,b,c,d,e,f,g]; by=string) # hide\nvectortime[8] = @elapsed sort!([a,b,c,d,e,f,g,h]; by=string) # hide\nvectortime[9] = @elapsed sort!([a,b,c,d,e,f,g,h,i]; by=string) # hide\nvectortime[10] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j]; by=string) # hide\nvectortime[11] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k]; by=string) # hide\nvectortime[12] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l]; by=string) # hide\nvectortime[13] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m]; by=string) # hide\nvectortime[14] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n]; by=string) # hide\nvectortime[15] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o]; by=string) # hide\nvectortime[16] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p]; by=string) # hide\nvectortime[17] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q]; by=string) # hide\nvectortime[18] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r]; by=string) # hide\nvectortime[19] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s]; by=string) # hide\nvectortime[20] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t]; by=string) # hide\nvectortime[21] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u]; by=string) # hide\nvectortime[22] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v]; by=string) # hide\nvectortime[23] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w]; by=string) # hide\n\nplot([swapsorttime vectortime]) # hide","category":"page"},{"location":"benchmark/#Runtime-2","page":"Benchmarks","title":"Runtime","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"swapsorttime[1] = @belapsed swapsort(a; by=string) # hide\nswapsorttime[2] = @belapsed swapsort(a,b; by=string) # hide\nswapsorttime[3] = @belapsed swapsort(a,b,c; by=string) # hide\nswapsorttime[4] = @belapsed swapsort(a,b,c,d; by=string) # hide\nswapsorttime[5] = @belapsed swapsort(a,b,c,d,e; by=string) # hide\nswapsorttime[6] = @belapsed swapsort(a,b,c,d,e,f; by=string) # hide\nswapsorttime[7] = @belapsed swapsort(a,b,c,d,e,f,g; by=string) # hide\nswapsorttime[8] = @belapsed swapsort(a,b,c,d,e,f,g,h; by=string) # hide\nswapsorttime[9] = @belapsed swapsort(a,b,c,d,e,f,g,h,i; by=string) # hide\nswapsorttime[10] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j; by=string) #hide\nswapsorttime[11] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k; by=string) # hide\nswapsorttime[12] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l; by=string) # hide\nswapsorttime[13] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m; by=string) # hide\nswapsorttime[14] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n; by=string) # hide\nswapsorttime[15] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o; by=string) # hide\nswapsorttime[16] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p; by=string) # hide\nswapsorttime[17] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q; by=string) # hide\nswapsorttime[18] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r; by=string) # hide\nswapsorttime[19] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s; by=string) # hide\nswapsorttime[20] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t; by=string) # hide\nswapsorttime[21] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u; by=string) # hide\nswapsorttime[22] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v; by=string) # hide\nswapsorttime[23] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w; by=string) # hide\n\nvectortime[1] = @belapsed sort!([a]; by=string) # hide\nvectortime[2] = @belapsed sort!([a,b]; by=string) # hide\nvectortime[3] = @belapsed sort!([a,b,c]; by=string) # hide\nvectortime[4] = @belapsed sort!([a,b,c,d]; by=string) # hide\nvectortime[5] = @belapsed sort!([a,b,c,d,e]; by=string) # hide\nvectortime[6] = @belapsed sort!([a,b,c,d,e,f]; by=string) # hide\nvectortime[7] = @belapsed sort!([a,b,c,d,e,f,g]; by=string) # hide\nvectortime[8] = @belapsed sort!([a,b,c,d,e,f,g,h]; by=string) # hide\nvectortime[9] = @belapsed sort!([a,b,c,d,e,f,g,h,i]; by=string) # hide\nvectortime[10] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j]; by=string) # hide\nvectortime[11] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k]; by=string) # hide\nvectortime[12] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l]; by=string) # hide\nvectortime[13] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m]; by=string) # hide\nvectortime[14] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n]; by=string) # hide\nvectortime[15] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o]; by=string) # hide\nvectortime[16] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p]; by=string) # hide\nvectortime[17] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q]; by=string) # hide\nvectortime[18] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r]; by=string) # hide\nvectortime[19] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s]; by=string) # hide\nvectortime[20] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t]; by=string) # hide\nvectortime[21] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u]; by=string) # hide\nvectortime[22] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v]; by=string) # hide\nvectortime[23] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w]; by=string) # hide\n\nplot([swapsorttime vectortime]) # hide","category":"page"},{"location":"#SwapSort.jl","page":"SwapSort.jl","title":"SwapSort.jl","text":"","category":"section"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"This package is intended to be a successor of SortingNetworks.jl. This package relies on the existing sorters which are currently copied from SorterHunter, a C++ project. For a visualization of the algorithms, see here.","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"PROS\nSupports lt and by keywords.\nEasier to to add new algorithms as all codes are generated.\nSupports sorting across different types. Note that type stability will become a problem in this case.\nCONS\nVery long precompilation (~55s on my machine). The current bottleneck is JSON.parsefile. The importing is fine (~30ms).\nHarder to troubleshoot since the most important things are written in macros.\nDoes not support sorting a vector. The reason is that Base.sort is efficient enough for a vector.\nDoes not support sorting a tuple at present.","category":"page"},{"location":"#Internals","page":"SwapSort.jl","title":"Internals","text":"","category":"section"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"There are many internal functions in the form of swapsortN_L_D(::Vararg{Any,N}). N refers to the data size, L refers to the number of comparisons/swaps. Although currently unsupported, it's possible to execute some swaps in parallel and D refers to the number of steps when computing in parallel. All available (N,L,D) triples are listed at SwapSort.SORTERS.","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"show(SwapSort.SORTERS)","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"The exported swapsort at present chooses the least available L for each N. For example, swapsort(a,b) = swapsort2_1_1(a,b). The choices are listed at SwapSort.BESTSIZE.","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"show(SwapSort.BESTSIZE)","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"The exported tuplesort is just another wrapper. It uses a different name as swapsort because otherwise it would be ambiguous whether the tuple is considered as one element or a group of elements. We note that TupleTools.jl uses merge sort on tuples.","category":"page"},{"location":"#Performance","page":"SwapSort.jl","title":"Performance","text":"","category":"section"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"The sorting algorithm is called sorting network. It's not the most efficient algorithm for general purpose, but in Julia, it excels at sorting a few discrete variables, as collecting/splatting is very slow.","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"StaticArrays.jl implements BitonicSort which is a special case of sorting network. It is more flexible, but has two drawbacks:","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"The import time of StaticArrays is 10x slower than SwapSort.\nSorting a few variables needs to pack them into a static vector. The packing in Julia is slow.","category":"page"},{"location":"docstrings/#Docstrings","page":"Docstrings","title":"Docstrings","text":"","category":"section"},{"location":"docstrings/","page":"Docstrings","title":"Docstrings","text":"Modules = [SwapSort]","category":"page"},{"location":"docstrings/#SwapSort._filename-Tuple{Any, Any, Any}","page":"Docstrings","title":"SwapSort._filename","text":"_filename(N,L,D)\n\nThe file that contains the infomation of constructing swapsortN_L_D.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.compswap-Tuple{Any, Any}","page":"Docstrings","title":"SwapSort.compswap","text":"compswap(i,j)\n\nThe expression ai, aj = min_max(ai, aj; kw...)\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.keywords-Tuple{}","page":"Docstrings","title":"SwapSort.keywords","text":"keywords()\n\nThe expression kw... in a function definition.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.localval-Tuple{Any}","page":"Docstrings","title":"SwapSort.localval","text":"localval(i)\n\nThe i-th variable name ai.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.min_max-Tuple{Any, Any}","page":"Docstrings","title":"SwapSort.min_max","text":"min_max(x, y; lt=isless, by=identity) = lt(by(x), by(y)) ? (x,y) : (y,x)\n\nThe same as Base.minmax, but supports lt and by keywords which works as those in Base.sort.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.returnvals-Tuple{Any}","page":"Docstrings","title":"SwapSort.returnvals","text":"returnvals(N)\n\nThe expression return a1, a2, ..., a(N-1).\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.swapsort-Tuple{Any}","page":"Docstrings","title":"SwapSort.swapsort","text":"swapsort(a...; lt=isless, by=identity)\n\nSort the arguments, returning a sorted tuple. lt and by keywords work the same as Base.sort. swapsort supports up to 64 arguments. See also tuplesort.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.tuplesort","page":"Docstrings","title":"SwapSort.tuplesort","text":"tuplesort(t::Tuple; lt=isless, by=identity)\n\nReturn a sorted tuple. lt and by keywords work the same as Base.sort. tuplesort calls swapsort and supports at most 64 elements.\n\n\n\n\n\n","category":"function"},{"location":"docstrings/#SwapSort.varstring-Tuple{Any}","page":"Docstrings","title":"SwapSort.varstring","text":"varstring(N)\n\nReturns the string of argument list \"a0,a1,...,a(N-1)\".\n\n\n\n\n\n","category":"method"}] +[{"location":"benchmark/#Benchmarks","page":"Benchmarks","title":"Benchmarks","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"The benchmarks are generated by the GitHub Actions. ","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"using InteractiveUtils, Pkg","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"versioninfo()\nPkg.status()","category":"page"},{"location":"benchmark/#Package-loading","page":"Benchmarks","title":"Package loading","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"The precompilation is very slow since the package reads many json files and build sorting methods based on them.","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"@time Pkg.precompile(\"SwapSort\")\n@time using SwapSort","category":"page"},{"location":"benchmark/#Same-type-(type-stable)","page":"Benchmarks","title":"Same type (type-stable)","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"When sorting variables of the same type, swapsort has longer compilation time but from 5x to 100x runtime depending on the sorting size. To save the build time of the doc, this page only contains a simplified benchmark. For the full benchmark, run the script.","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"using SwapSort, StaticArrays, Plots, BenchmarkTools\nusing LaTeXStrings # hide\nBenchmarkTools.DEFAULT_PARAMETERS.seconds = 0.5 # hide\nsamples = [1,2,4,8,16,32,64]\nswapsorttime = zeros(7)\nsvectortime = zeros(7)\nvectortime = zeros(7)\ndefault(background_color=:transparent, foreground_color=:gray, yaxis=:log, xaxis=:log2, xticks=(samples, [L\"2^0\", L\"2^1\", L\"2^2\", L\"2^3\", L\"2^4\", L\"2^5\", L\"2^6\"])) # hide\na,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De = rand(64)","category":"page"},{"location":"benchmark/#Compilation","page":"Benchmarks","title":"Compilation","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"swapsorttime[1] = @elapsed swapsort(a)\nswapsorttime[2] = @elapsed swapsort(a,b)\nswapsorttime[3] = @elapsed swapsort(a,b,c,d)\nswapsorttime[4] = @elapsed swapsort(a,b,c,d,e,f,g,h)\nswapsorttime[5] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)\nswapsorttime[6] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F)\nswapsorttime[7] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De)\n\nsvectortime[1] = @elapsed sort(SVector(a))\n#= Do the same thing. Lines are hidden=#\nsvectortime[2] = @elapsed sort(SVector(a,b)) # hide\nsvectortime[3] = @elapsed sort(SVector(a,b,c,d)) # hide\nsvectortime[4] = @elapsed sort(SVector(a,b,c,d,e,f,g,h)) # hide\nsvectortime[5] = @elapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)) # hide\nsvectortime[6] = @elapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F)) # hide\nsvectortime[7] = @elapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De)) # hide\n\nvectortime[1] = @elapsed sort!([a])\n#= Do the same thing. Lines are hidden=#\nvectortime[2] = @elapsed sort!([a,b]) # hide\nvectortime[3] = @elapsed sort!([a,b,c,d]) # hide\nvectortime[4] = @elapsed sort!([a,b,c,d,e,f,g,h]) # hide\nvectortime[5] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p]) # hide\nvectortime[6] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F]) # hide\nvectortime[7] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De]) # hide\n\nplot(samples, [swapsorttime svectortime vectortime], labels=[\"swapsort\" \"SVector\" \"Vector\"])","category":"page"},{"location":"benchmark/#Runtime","page":"Benchmarks","title":"Runtime","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"Replacing @elapsed with @belapsed, we get the runtime.","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"swapsorttime[1] = @belapsed swapsort(a) # hide\nswapsorttime[2] = @belapsed swapsort(a,b) # hide\nswapsorttime[3] = @belapsed swapsort(a,b,c,d) # hide\nswapsorttime[4] = @belapsed swapsort(a,b,c,d,e,f,g,h) # hide\nswapsorttime[5] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) # hide\nswapsorttime[6] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F) # hide\nswapsorttime[7] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De) # hide\n\nsvectortime[1] = @belapsed sort(SVector(a)) # hide\nsvectortime[2] = @belapsed sort(SVector(a,b)) # hide\nsvectortime[3] = @belapsed sort(SVector(a,b,c,d)) # hide\nsvectortime[4] = @belapsed sort(SVector(a,b,c,d,e,f,g,h)) # hide\nsvectortime[5] = @belapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)) # hide\nsvectortime[6] = @belapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F)) # hide\nsvectortime[7] = @belapsed sort(SVector(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De)) # hide\n\nvectortime[1] = @belapsed sort!([a]) # hide\nvectortime[2] = @belapsed sort!([a,b]) # hide\nvectortime[3] = @belapsed sort!([a,b,c,d]) # hide\nvectortime[4] = @belapsed sort!([a,b,c,d,e,f,g,h]) # hide\nvectortime[5] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p]) # hide\nvectortime[6] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F]) # hide\nvectortime[7] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ja,Fe,Ma,Ap,My,Ju,Jl,Au,Se,Oc,No,De]) # hide\n\nplot(samples, [swapsorttime svectortime vectortime], labels=[\"swapsort\" \"SVector\" \"Vector\"])","category":"page"},{"location":"benchmark/#Different-types-(type-unstable)","page":"Benchmarks","title":"Different types (type-unstable)","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"When sorting across different types, methods based on Tuple or Vararg suffer from type inference as different orders have different types. As a result, the compilation time can be a lot longer. In this benchmark, we consider up to 23 variables of different types, including","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"7 Number types: Int, Float, Irrational, Complex, Rational, BigInt, BigFloat\n8 Collection types: Tuple, Set, Dict, Matrix, Vector, String, Range, NamedTuple\n8 Other types: CartesianIndex, Pair, Function, Symbol, Type, Module, Nothing, Char","category":"page"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"using Random, SwapSort, Plots, BenchmarkTools, StaticArrays\ndefault(background_color=:transparent, foreground_color=:gray, yaxis=:log, xaxis=:identity, xticks=1:23) # hide\nBenchmarkTools.DEFAULT_PARAMETERS.seconds = 0.5 # hide\na,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w = shuffle(\n [rand(Int), rand(), π, im, 1//2, BigInt(rand(Int128)), rand(BigFloat), \n (1,2), Set([1,2]), Dict(1=>2), rand(2,2), rand(Int, 10), randstring(), 1:10, (a=1,b=2), \n CartesianIndex(1,2), 1=>2, sin, :sin, typeof(sin), SwapSort, nothing, 'a'])\nswapsorttime = zeros(23) # hide\nvectortime = zeros(23) # hide","category":"page"},{"location":"benchmark/#Compilation-2","page":"Benchmarks","title":"Compilation","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"swapsorttime[1] = @elapsed swapsort(a; by=string) # hide\nswapsorttime[2] = @elapsed swapsort(a,b; by=string) # hide\nswapsorttime[3] = @elapsed swapsort(a,b,c; by=string) # hide\nswapsorttime[4] = @elapsed swapsort(a,b,c,d; by=string) # hide\nswapsorttime[5] = @elapsed swapsort(a,b,c,d,e; by=string) # hide\nswapsorttime[6] = @elapsed swapsort(a,b,c,d,e,f; by=string) # hide\nswapsorttime[7] = @elapsed swapsort(a,b,c,d,e,f,g; by=string) # hide\nswapsorttime[8] = @elapsed swapsort(a,b,c,d,e,f,g,h; by=string) # hide\nswapsorttime[9] = @elapsed swapsort(a,b,c,d,e,f,g,h,i; by=string) # hide\nswapsorttime[10] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j; by=string) # hide\nswapsorttime[11] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k; by=string) # hide\nswapsorttime[12] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l; by=string) # hide\nswapsorttime[13] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m; by=string) # hide\nswapsorttime[14] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n; by=string) # hide\nswapsorttime[15] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o; by=string) # hide\nswapsorttime[16] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p; by=string) # hide\nswapsorttime[17] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q; by=string) # hide\nswapsorttime[18] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r; by=string) # hide\nswapsorttime[19] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s; by=string) # hide\nswapsorttime[20] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t; by=string) # hide\nswapsorttime[21] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u; by=string) # hide\nswapsorttime[22] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v; by=string) # hide\nswapsorttime[23] = @elapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w; by=string) # hide\n\nvectortime[1] = @elapsed sort!([a]; by=string) # hide\nvectortime[2] = @elapsed sort!([a,b]; by=string) # hide\nvectortime[3] = @elapsed sort!([a,b,c]; by=string) # hide\nvectortime[4] = @elapsed sort!([a,b,c,d]; by=string) # hide\nvectortime[5] = @elapsed sort!([a,b,c,d,e]; by=string) # hide\nvectortime[6] = @elapsed sort!([a,b,c,d,e,f]; by=string) # hide\nvectortime[7] = @elapsed sort!([a,b,c,d,e,f,g]; by=string) # hide\nvectortime[8] = @elapsed sort!([a,b,c,d,e,f,g,h]; by=string) # hide\nvectortime[9] = @elapsed sort!([a,b,c,d,e,f,g,h,i]; by=string) # hide\nvectortime[10] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j]; by=string) # hide\nvectortime[11] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k]; by=string) # hide\nvectortime[12] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l]; by=string) # hide\nvectortime[13] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m]; by=string) # hide\nvectortime[14] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n]; by=string) # hide\nvectortime[15] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o]; by=string) # hide\nvectortime[16] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p]; by=string) # hide\nvectortime[17] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q]; by=string) # hide\nvectortime[18] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r]; by=string) # hide\nvectortime[19] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s]; by=string) # hide\nvectortime[20] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t]; by=string) # hide\nvectortime[21] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u]; by=string) # hide\nvectortime[22] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v]; by=string) # hide\nvectortime[23] = @elapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w]; by=string) # hide\n\nplot([swapsorttime vectortime]) # hide","category":"page"},{"location":"benchmark/#Runtime-2","page":"Benchmarks","title":"Runtime","text":"","category":"section"},{"location":"benchmark/","page":"Benchmarks","title":"Benchmarks","text":"swapsorttime[1] = @belapsed swapsort(a; by=string) # hide\nswapsorttime[2] = @belapsed swapsort(a,b; by=string) # hide\nswapsorttime[3] = @belapsed swapsort(a,b,c; by=string) # hide\nswapsorttime[4] = @belapsed swapsort(a,b,c,d; by=string) # hide\nswapsorttime[5] = @belapsed swapsort(a,b,c,d,e; by=string) # hide\nswapsorttime[6] = @belapsed swapsort(a,b,c,d,e,f; by=string) # hide\nswapsorttime[7] = @belapsed swapsort(a,b,c,d,e,f,g; by=string) # hide\nswapsorttime[8] = @belapsed swapsort(a,b,c,d,e,f,g,h; by=string) # hide\nswapsorttime[9] = @belapsed swapsort(a,b,c,d,e,f,g,h,i; by=string) # hide\nswapsorttime[10] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j; by=string) #hide\nswapsorttime[11] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k; by=string) # hide\nswapsorttime[12] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l; by=string) # hide\nswapsorttime[13] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m; by=string) # hide\nswapsorttime[14] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n; by=string) # hide\nswapsorttime[15] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o; by=string) # hide\nswapsorttime[16] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p; by=string) # hide\nswapsorttime[17] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q; by=string) # hide\nswapsorttime[18] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r; by=string) # hide\nswapsorttime[19] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s; by=string) # hide\nswapsorttime[20] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t; by=string) # hide\nswapsorttime[21] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u; by=string) # hide\nswapsorttime[22] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v; by=string) # hide\nswapsorttime[23] = @belapsed swapsort(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w; by=string) # hide\n\nvectortime[1] = @belapsed sort!([a]; by=string) # hide\nvectortime[2] = @belapsed sort!([a,b]; by=string) # hide\nvectortime[3] = @belapsed sort!([a,b,c]; by=string) # hide\nvectortime[4] = @belapsed sort!([a,b,c,d]; by=string) # hide\nvectortime[5] = @belapsed sort!([a,b,c,d,e]; by=string) # hide\nvectortime[6] = @belapsed sort!([a,b,c,d,e,f]; by=string) # hide\nvectortime[7] = @belapsed sort!([a,b,c,d,e,f,g]; by=string) # hide\nvectortime[8] = @belapsed sort!([a,b,c,d,e,f,g,h]; by=string) # hide\nvectortime[9] = @belapsed sort!([a,b,c,d,e,f,g,h,i]; by=string) # hide\nvectortime[10] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j]; by=string) # hide\nvectortime[11] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k]; by=string) # hide\nvectortime[12] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l]; by=string) # hide\nvectortime[13] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m]; by=string) # hide\nvectortime[14] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n]; by=string) # hide\nvectortime[15] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o]; by=string) # hide\nvectortime[16] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p]; by=string) # hide\nvectortime[17] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q]; by=string) # hide\nvectortime[18] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r]; by=string) # hide\nvectortime[19] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s]; by=string) # hide\nvectortime[20] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t]; by=string) # hide\nvectortime[21] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u]; by=string) # hide\nvectortime[22] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v]; by=string) # hide\nvectortime[23] = @belapsed sort!([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w]; by=string) # hide\n\nplot([swapsorttime vectortime]) # hide","category":"page"},{"location":"#SwapSort.jl","page":"SwapSort.jl","title":"SwapSort.jl","text":"","category":"section"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"This package is intended to be a successor of SortingNetworks.jl. This package relies on the existing sorters which are currently copied from SorterHunter, a C++ project. For a visualization of the algorithms, see here.","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"PROS\nSupports lt and by keywords.\nEasier to to add new algorithms as all codes are generated.\nSupports sorting across different types. Note that type stability will become a problem in this case.\nCONS\nVery long precompilation (~30s on CI). The current bottleneck is JSON.parsefile. The compilation is ok and the importing is fast.\nHarder to troubleshoot since the most important things are written in macros.\nDoes not support sorting a vector. The reason is that Base.sort is efficient enough for a vector.\nDoes not support sorting a tuple at present.","category":"page"},{"location":"#Internals","page":"SwapSort.jl","title":"Internals","text":"","category":"section"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"There are many internal functions in the form of swapsortN_L_D(::Vararg{Any,N}). N refers to the data size, L refers to the number of comparisons/swaps. Although currently unsupported, it's possible to execute some swaps in parallel and D refers to the number of steps when computing in parallel. All available (N,L,D) triples are listed at SwapSort.SORTERS.","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"show(SwapSort.SORTERS)","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"The exported swapsort at present chooses the least available L for each N. For example, swapsort(a,b) = swapsort2_1_1(a,b). The choices are listed at SwapSort.BESTSIZE.","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"show(SwapSort.BESTSIZE)","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"The exported tuplesort is just another wrapper. It uses a different name as swapsort because otherwise it would be ambiguous whether the tuple is considered as one element or a group of elements. We note that TupleTools.jl uses merge sort on tuples.","category":"page"},{"location":"#Performance","page":"SwapSort.jl","title":"Performance","text":"","category":"section"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"The sorting algorithm is called sorting network. It's not the most efficient algorithm for general purpose, but in Julia, it excels at sorting a few discrete variables, as collecting/splatting is very slow.","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"StaticArrays.jl implements BitonicSort which is a special case of sorting network. It is more flexible, but has two drawbacks:","category":"page"},{"location":"","page":"SwapSort.jl","title":"SwapSort.jl","text":"The import time of StaticArrays is 10x slower than SwapSort.\nSorting a few variables needs to pack them into a static vector. The packing in Julia is slow.","category":"page"},{"location":"docstrings/#Docstrings","page":"Docstrings","title":"Docstrings","text":"","category":"section"},{"location":"docstrings/","page":"Docstrings","title":"Docstrings","text":"Modules = [SwapSort]","category":"page"},{"location":"docstrings/#SwapSort._filename-Tuple{Any, Any, Any}","page":"Docstrings","title":"SwapSort._filename","text":"_filename(N,L,D)\n\nThe file that contains the infomation of constructing swapsortN_L_D.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.compswap-Tuple{Any, Any}","page":"Docstrings","title":"SwapSort.compswap","text":"compswap(i,j)\n\nThe expression ai, aj = min_max(ai, aj; kw...)\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.keywords-Tuple{}","page":"Docstrings","title":"SwapSort.keywords","text":"keywords()\n\nThe expression kw... in a function definition.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.localval-Tuple{Any}","page":"Docstrings","title":"SwapSort.localval","text":"localval(i)\n\nThe i-th variable name ai.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.min_max-Tuple{Any, Any}","page":"Docstrings","title":"SwapSort.min_max","text":"min_max(x, y; lt=isless, by=identity) = lt(by(x), by(y)) ? (x,y) : (y,x)\n\nThe same as Base.minmax, but supports lt and by keywords which works as those in Base.sort.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.returnvals-Tuple{Any}","page":"Docstrings","title":"SwapSort.returnvals","text":"returnvals(N)\n\nThe expression return a1, a2, ..., a(N-1).\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.swapsort-Tuple{Any}","page":"Docstrings","title":"SwapSort.swapsort","text":"swapsort(a...; lt=isless, by=identity)\n\nSort the arguments, returning a sorted tuple. lt and by keywords work the same as Base.sort. swapsort supports up to 64 arguments. See also tuplesort.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.tuplesort-Tuple{Tuple{Any}}","page":"Docstrings","title":"SwapSort.tuplesort","text":"tuplesort(t::Tuple; lt=isless, by=identity)\n\nReturn a sorted tuple. lt and by keywords work the same as Base.sort. tuplesort calls swapsort and supports at most 64 elements.\n\n\n\n\n\n","category":"method"},{"location":"docstrings/#SwapSort.varstring-Tuple{Any}","page":"Docstrings","title":"SwapSort.varstring","text":"varstring(N)\n\nReturns the string of argument list \"a0,a1,...,a(N-1)\".\n\n\n\n\n\n","category":"method"}] }