RosettaCodeData/Task/Sort-an-array-of-composite-structures/Lua/sort-an-array-of-composite-structures.lua

11 lines
210 B
Lua
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
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