-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsort.lua
More file actions
38 lines (34 loc) · 654 Bytes
/
Copy pathsort.lua
File metadata and controls
38 lines (34 loc) · 654 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
io.output("sorting.lua")
function escape(char)
char = string.char(char)
if char == "\"" or char == "\\" then return "\\" .. char end
return char
end
io.write(
[[
malgorithm{
name = "sort", -- sorts number string
]])
for i = 0, 9 do
for j = 0, 9 do
if i > j then
io.write(string.format(" {[\"%d%d\"] = \"%d%d\"},\n", i, j, j, i))
end
end
end
io.write("}\n\n")
io.write(
[[
malgorithm{
name = "sortall", -- sorts string
]])
for i = 33, 126 do
for j = 33, 126 do
if i > j then
local i = escape(i)
local j = escape(j)
io.write(string.format(" {[\"%s%s\"] = \"%s%s\"},\n", i, j, j, i))
end
end
end
io.write("}\n")