Heapsort in Lua