Skip to content

Instantly share code, notes, and snippets.

View Jarodwr's full-sized avatar
🐛
not much

Jarodwr

🐛
not much
View GitHub Profile
-- This is the LuaJIT implementation of Smoothsort [1], a comparison-based
-- sorting algorithm with worst-case asymptotic O(n log n) behaviour, best-case
-- O(n) behaviour, and a smooth transition in between. Largely based on the C++
-- code by Keith Schwarz [2], translated to LuaJIT by Lesley De Cruz.
-- [1] Dijkstra, E. W. (1982). Smoothsort, an alternative for sorting in situ.
-- Science of Computer Programming, 1(3), 223-233.
-- [2] Schwarz, K. Smoothsort demystified. http://www.keithschwarz.com/smoothsort/.
local ffi = require("ffi")