LUA 排序算法和性能分析[1]:table.sort

先看一下LUA 自带的 table.sort 

 

 

 

math.randomseed(os.time());

local real_print = print;
local nLine = 0;
function print(...)
    real_print(nLine, ...)
    nLine = nLine + 1;
end


local t = {}

local function dump()
    -- print(table.concat(t, ","));
end;



for i = 1, 256 do
    table.insert(t, math.random(i), i);
end

function table_sort()
    table.sort(t);
    dump()
end

-- table_sort() -- 0.3

LUA 排序算法和性能分析[2]:冒泡排序算法

https://blog.csdn.net/warrially/article/details/78852647

LUA 排序算法和性能分析[3]:选择排序算法

https://blog.csdn.net/warrially/article/details/78852711

LUA 排序算法和性能分析[4]:快速排序算法

https://blog.csdn.net/warrially/article/details/78852758

LUA 排序算法和性能分析[5]:插入排序算法

https://blog.csdn.net/warrially/article/details/78852819

LUA 排序算法和性能分析[6]:归并排序算法

https://blog.csdn.net/warrially/article/details/78852866

 

你可能感兴趣的:(LUA 排序算法和性能分析[1]:table.sort)