1/alichraghi/zort v0.23

a lot of sorting algorithms written in zig


Zort

Implementation of 13 sorting algorithms in Zig

| Algorithm | Custom Comparison | Zero Allocation | | ----------------------- | ----------------- | --------------- | | Bubble | ✅ | ✅ | | Comb | ✅ | ✅ | | Heap | ✅ | ✅ | | Insertion | ✅ | ✅ | | Merge | ✅ | ❌ | | PDQ | ✅ | ✅ | | Quick | ✅ | ✅ | | Radix (no negative yet) | ❌ | ❌ | | Selection | ✅ | ✅ | | Shell | ✅ | ✅ | | Tail | ✅ | ❌ | | Tim | ✅ | ❌ | | Twin | ✅ | ❌ |

Usage

const zort = @import("zort");

fn asc(a: u8, b: u8) bool {
    return a < b;
}

pub fn main() !void {
    var arr = [_]u8{ 9, 1, 4, 12, 3, 4 };
    try zort.quickSort(u8, &arr, asc);
}

Benchmarks

Raspberry Pi 4 with 8GB RAM

gantt
    title Sorting 10 million items
    dateFormat x
    axisFormat %S s
    tim 0.617: 0,617
    pdq 1.306: 0,1306
    quick 2.553: 0,2552
    radix 2.439: 0,2441
    tail 3.232: 0,3232
    twin 3.248: 0,3248
    std_block_merge 4.285: 0,4283
    comb 4.746: 0,4747
    shell 7.645: 0,7643

Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz

gantt
    title Sorting 10 million items
    dateFormat x
    axisFormat %S s
    tim 0.215: 0,215
    pdq 0.503: 0,503
    quick 1.152: 0,1152
    radix 1.101: 0,1101
    tail 1.396: 0,1396
    twin 1.401: 0,1401
    std_block_merge 1.594: 0,1594
    comb 1.741: 0,1741
    shell 2.500: 0,2501

Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz

gantt
    title Sorting 10 million items
    dateFormat x
    axisFormat %S.%L
    std_block_merge : 0,1699
    quick : 0,994
    tim : 0,159
    comb : 0,1827
    shell : 0,2368
    heap : 0,3733
    radix : 0,1468
    twin : 0,1273

Package Contents

  • .gitattributes
  • benchmark/run_bench.zig
  • LICENSE
  • build.zig
  • benchmark.sh
  • zigmod.yml
  • src/insertion.zig
  • src/tim.zig
  • src/radix.zig
  • src/bubble.zig
  • src/merge.zig
  • src/shell.zig
  • src/tail.zig
  • src/pdqsort.zig
  • src/selection.zig
  • src/main.zig
  • src/test.zig
  • src/heap.zig
  • src/twin.zig
  • src/quick.zig
  • src/comb.zig
  • README.md
  • .gitignore

History

Published On Tree @ Commit Size
v0.34 Thu, 22 Sep 2022 19:25:40 UTC Tree 114.859 KB
v0.33 Sat, 27 Aug 2022 03:47:22 UTC Tree 118.303 KB
v0.32 Mon, 22 Aug 2022 18:21:47 UTC Tree 117.782 KB
v0.31 Mon, 08 Aug 2022 21:38:40 UTC Tree 117.778 KB
v0.30 Sat, 06 Aug 2022 09:53:24 UTC Tree 88.812 KB
v0.29 Fri, 05 Aug 2022 12:07:15 UTC Tree 82.142 KB
v0.28 Fri, 05 Aug 2022 11:10:58 UTC Tree 56.816 KB
v0.27 Fri, 05 Aug 2022 11:08:02 UTC Tree 56.822 KB
v0.26 Mon, 01 Aug 2022 19:46:11 UTC Tree 54.825 KB
v0.25 Mon, 01 Aug 2022 06:11:13 UTC Tree 49.457 KB
v0.24 Mon, 01 Aug 2022 06:09:33 UTC Tree 49.668 KB
v0.23 Sat, 30 Jul 2022 22:35:53 UTC Tree 49.218 KB
v0.22 Sat, 30 Jul 2022 20:57:59 UTC Tree 49.386 KB
v0.21 Sat, 30 Jul 2022 20:43:16 UTC Tree 49.209 KB
v0.20 Thu, 28 Jul 2022 20:32:09 UTC Tree 44.887 KB
v0.19 Sun, 17 Jul 2022 06:36:58 UTC Tree 29.603 KB
v0.18 Thu, 19 May 2022 15:22:44 UTC Tree 27.198 KB
v0.17 Thu, 19 May 2022 15:17:40 UTC Tree 27.758 KB
v0.16 Thu, 19 May 2022 15:08:25 UTC Tree 27.285 KB
v0.15 Thu, 19 May 2022 14:10:51 UTC Tree 27.107 KB
v0.14 Sat, 07 May 2022 05:36:29 UTC Tree 29.861 KB
v0.13 Wed, 04 May 2022 14:45:20 UTC Tree 29.380 KB
v0.12 Mon, 02 May 2022 10:54:12 UTC Tree 61.833 KB
v0.11 Mon, 02 May 2022 10:49:59 UTC Tree 61.833 KB
v0.10 Sat, 23 Apr 2022 15:57:47 UTC Tree 52.633 KB
v0.9 Sun, 20 Mar 2022 18:47:44 UTC Tree 52.641 KB
v0.8 Sun, 20 Mar 2022 11:38:52 UTC Tree 52.973 KB
v0.7 Fri, 18 Mar 2022 16:32:02 UTC Tree 50.603 KB
v0.6 Fri, 18 Mar 2022 16:31:29 UTC Tree 50.733 KB
v0.5 Fri, 18 Mar 2022 16:27:12 UTC Tree 50.733 KB
v0.4 Fri, 18 Mar 2022 16:24:57 UTC Tree 50.765 KB
v0.3 Fri, 18 Mar 2022 16:21:29 UTC Tree 50.672 KB
v0.2 Thu, 17 Mar 2022 11:35:28 UTC Tree 19.215 KB
v0.1 Wed, 16 Mar 2022 16:50:48 UTC Tree 19.215 KB