timsort2

timsort algorithm implemented in Nim

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version Unknown
License Apache-2.0
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:25

Installation

nimble install timsort2
choosenim install timsort2
git clone https://github.com/xrfez/timsort

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
timsort2 - - - - - - -

Source

Repository https://github.com/xrfez/timsort
Homepage https://github.com/xrfez/timsort
Registry Source nimble_official

README

timsort

nimble install timsort2

This library has no dependencies other than the Nim standard library

About

TimSort is a sorting algorithm based on Insertion Sort and Merge Sort. Used in Java’s Arrays.sort() as well as Python’s sorted() and sort(). First sort small pieces using Insertion Sort, then merges the pieces using a merge of merge sort. Support for sorting 2D containers with multiple criteria. Benchmarks show a 15-20% improvement over std/algorithm.sort on suedo random data.

var arr = @[6, 5, 4, 3, 2, 1].timSort
assert arr == @[1, 2, 3, 4, 5, 6]

var arr = @["bacon", "ham", "eggs"].timSort
assert arr == @["bacon", "eggs", "ham"]

var arr = @[@[4, 4, 2, 1], @[4, 3, 1, 2], @[1, 2, 3, 4]].timsort(0, 1)
assert arr = @[@[1, 2, 4, 4], @[2, 1, 3, 4], @[4, 3, 2, 1]]

It will sort 2D sequences and accepts criteria as varargs