This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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") |