RosettaCodeData/Task/Reverse-words-in-a-string/Lua/reverse-words-in-a-string-1.lua
2026-04-30 12:34:36 -04:00

13 lines
273 B
Lua

function splittokens(s)
local res = {}
for w in s:gmatch("%S+") do
res[#res+1] = w
end
return res
end
function reverse(a,b) return a>b end
for line in io.lines"input.txt" do
print(table.concat(table.sort(splittokens(line), reverse), ' '))
end