lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, 08 May 2013 11:31:09 -0000, Eike Decker <zet23t@googlemail.com> wrote:

--- sorts arr in a stable manner via a simplified mergesort
-- the simplification is to avoid the dividing step and just start
-- merging arrays of size=1 (which are sorted by definition)
function msort_inplace(arr, goes_before)

for _,v in ipairs(msort_inplace({4,5,6,7,0,1,2,3})) do print(v) end

gives:

0
0
0
0
0
1
2
3