On Thu, Jan 10, 2019 at 12:11 PM Henning Hraban Ramm
a Lua pairs table, the order can be arbitrary.
sure , the *default* __pairs gives pseudo-arbitrary order, but you can always use metatable: -- -- test.lua -- local _c,_t=0,{} local t = {} setmetatable(t, { __newindex = function(tbl, k, v) _c=_c+1 _t[_c]=k rawset(tbl, k, v) end, __pairs = function(tbl) local i = 1 return function(tbl,k) k = _t[i] i=i+1 return k,tbl[k] end, tbl,nil end, }) t['a']= 'aaa' t['3a']= '3aa' t['b']= 'baa' t['2b']= '2ba' t['c']= 'caa' t['2c']= '2ca' t['d']= 'daa' t['2d']= '2da' t['e']= 'eaa' t['2e']= '2ea' for k,v in pairs(t) do print(k,v) end $ mtxrun --script test.lua a aaa 3a 3aa b baa 2b 2ba c caa 2c 2ca d daa 2d 2da e eaa 2e 2ea -- luigi