All Projects → xiaodaigh → SortingLab.jl

xiaodaigh / SortingLab.jl

Licence: other
Faster sorting algorithms (sort and sortperm) for Julia

Programming Languages

julia
2034 projects

Projects that are alternatives of or similar to SortingLab.jl

radix-sorting
Radix sorting from the ground up
Stars: ✭ 27 (+35%)
Mutual labels:  sorting-algorithms, radix-sort, radixsort
Sorting-Algorithms
sorting algorithms in python
Stars: ✭ 15 (-25%)
Mutual labels:  sort, sorting-algorithms
ultra-sort
DSL for SIMD Sorting on AVX2 & AVX512
Stars: ✭ 29 (+45%)
Mutual labels:  sort, sorting-algorithms
Algods
Implementation of Algorithms and Data Structures, Problems and Solutions
Stars: ✭ 3,295 (+16375%)
Mutual labels:  sort, sorting-algorithms
FaceDetection.jl
A face detection algorithm using Viola-Jones' rapid object detection framework written in Julia
Stars: ✭ 13 (-35%)
Mutual labels:  julia-package, julialang
ShiftSort
Sorting algorithm quicker than MergeSort, and is adaptive and stable.
Stars: ✭ 39 (+95%)
Mutual labels:  sort, sorting-algorithms
data-structure-and-algorithm
Basic data structures, sorting algorithms, algorithms learning tools. 基本数据结构,排序算法,算法学习工具
Stars: ✭ 86 (+330%)
Mutual labels:  sort, sorting-algorithms
algorithms
The All ▲lgorithms documentation website.
Stars: ✭ 114 (+470%)
Mutual labels:  sort, sorting-algorithms
Javascript
A repository for All algorithms implemented in Javascript (for educational purposes only)
Stars: ✭ 16,117 (+80485%)
Mutual labels:  sort, sorting-algorithms
Java
All Algorithms implemented in Java
Stars: ✭ 42,893 (+214365%)
Mutual labels:  sort, sorting-algorithms
Pretty Algorithms
🌊 Pretty, common and useful algorithms with modern JS and beautiful tests
Stars: ✭ 2,163 (+10715%)
Mutual labels:  sort, sorting-algorithms
OmniSci.jl
Julia client for OmniSci GPU-accelerated SQL engine and analytics platform
Stars: ✭ 22 (+10%)
Mutual labels:  julia-package, julialang
Algorithms
Short explanations and implementations of different algorithms in multiple languages
Stars: ✭ 37 (+85%)
Mutual labels:  sort, sorting-algorithms
Algorithms Primer
A consolidated collection of resources for you to learn and understand algorithms and data structures easily.
Stars: ✭ 381 (+1805%)
Mutual labels:  sort, sorting-algorithms
Interview Questions
List of all the Interview questions practiced from online resources and books
Stars: ✭ 187 (+835%)
Mutual labels:  sort, sorting-algorithms
lua sort
Lua pure sort algorithm based on lib_table.c (from LuaJIT 2.1.0)
Stars: ✭ 21 (+5%)
Mutual labels:  sort, sorting-algorithms
PixelGlitch
Image glitch visualization using various Pixel Sorting methods for Processing
Stars: ✭ 25 (+25%)
Mutual labels:  sort
NaturalSort.Extension
🔀 Extension method for StringComparison that adds support for natural sorting (e.g. "abc1", "abc2", "abc10" instead of "abc1", "abc10", "abc2").
Stars: ✭ 94 (+370%)
Mutual labels:  sort
ECharts.jl
Julia package for the Apache ECharts v4 visualization library
Stars: ✭ 80 (+300%)
Mutual labels:  julialang
PySortDemo
Visualization of sorting algorithms, done in Python.
Stars: ✭ 21 (+5%)
Mutual labels:  sorting-algorithms
author title date
Dai ZJ
SortingLab README
2019--09-28

SortingLab

An alternative implementation of sorting algorithms and APIs. The ultimate aim is to contribute back to Julia base or SortingAlgorithms.jl. However, there is commitment to keep this package's API stable and supported, so other developers can rely on the implementation and API here.

Faster Sort and Sortperm

The main function exported by SortingLab is fsort and fsortperm which generally implements faster algorithms than sort and sortperm for CategoricalArrays.CategoricalVector, Vector{T}, Vector{Union{T, Missing}} where T is

  • Int*, UInt*, Float*, String

Usage

using SortingLab;
using Test
N = 1_000_000;
K = 100;

svec = rand("id".*string.(1:N÷K, pad=10), N);

svec_sorted = fsort(svec);
@test issorted(svec_sorted)
@test issorted(svec) == false
Test Passed
# faster string sortperm
sorted_idx = fsortperm(svec)
issorted(svec[sorted_idx]) #true

# in place string sort
fsort!(svec);
issorted(svec) # true
true
# CategoricalArray sort
using CategoricalArrays
pools = "id".*string.(1:100,3);
byvec = CategoricalArray{String, 1}(rand(UInt32(1):UInt32(length(pools)), N), CategoricalPool(pools, false));
byvec = compress(byvec);

byvec_sorted = fsort(byvec);
@test issorted(byvec_sorted)
Test Passed

Sorting Vector{Union{T, Missing}}

For vectors that contain missing, the sort and sortperm performance is often sub-optimal in Base and is not supported in SortingAlgorithms.jl's radixsort implementation. This is solved by SortingLab.jl fsort, see Benchmarks Section

using Test
using Missings: allowmissing
x = allowmissing(rand(1:10_000, 1_000_000))
x[rand(1:length(x), 100_000)] .= missing

using SortingLab
@test isequal(fsort(x), sort(x))
Test Passed

Benchmarks

Base.sort vs SortingLab.radixsort

Base.sort vs SortingLab.radixsort

Base.sort vs SortingLab.fsort

Base.sortperm vs SortingLab.sortperm

Benchmarking code

using SortingLab;
using BenchmarkTools;
import Random: randstring

N = 1_000_000;
K = 100;

svec = rand("id".*string.(1:N÷K, pad=10), N);
sort_id_1m = @belapsed sort($svec);
radixsort_id_1m = @belapsed radixsort($svec);

sortperm_id_1m = @belapsed sortperm($svec);
fsortperm_id_1m = @belapsed fsortperm($svec);

rsvec = rand([randstring(rand(1:32)) for i = 1:N÷K], N);
sort_r_1m = @belapsed sort($rsvec);
radixsort_r_1m = @belapsed radixsort($rsvec);

sortperm_r_1m = @belapsed sortperm($rsvec);
fsortperm_r_1m = @belapsed fsortperm($rsvec);

using Plots
using StatsPlots
groupedbar(
    repeat(["IDs", "Random len 32"], inner=2),
    [sort_id_1m, radixsort_id_1m, sort_r_1m, radixsort_r_1m],
    group = repeat(["Base.sort","SortingLab.radixsort"], outer = 2),
    title = "Strings sort (1m rows): Base vs SortingLab")
savefig("benchmarks/sort_vs_radixsort.png")

groupedbar(
    repeat(["IDs", "Random len 32"], inner=2),
    [sortperm_id_1m, fsortperm_id_1m, sortperm_r_1m, fsortperm_r_1m],
    group = repeat(["Base.sortperm","SortingLab.fsortperm"], outer = 2),
    title = "Strings sortperm (1m rows): Base vs SortingLab")
savefig("benchmarks/sortperm_vs_fsortperm.png")

Similar package

https://github.com/JuliaCollections/SortingAlgorithms.jl

Build status

Build Status

Coverage Status

codecov.io

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].