Lua does not have its own list
However, as @joachim noted, you can use some hacks to achieve it.
local comp = require 'comprehension' . new() comp 'table(v,k for k,v in pairs(_1))' {[3]=5, [5]=7}
This will give:
{[5]=3, [7]=5}
Note that comprehension does not work in simple version 5.2.x Lua. This requires the Penlight Lua libraries: http://stevedonovan.github.com/Penlight/api/index.html
You can also use MetaLua or LuaMacros
source share