RosettaCodeData/Task/Sort-an-array-of-composite-structures/Lua/sort-an-array-of-composite-structures.lua
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

10 lines
210 B
Lua

function sorting( a, b )
return a[1] < b[1]
end
tab = { {"C++", 1979}, {"Ada", 1983}, {"Ruby", 1995}, {"Eiffel", 1985} }
table.sort( tab, sorting )
for _, v in ipairs( tab ) do
print( unpack(v) )
end