- API -
dofile(reaper.AZ_GetLuaInitPath())
t = {"test1","test3","test2"}
x = {}
for index, value in pairs(t) do
x[index]= {}
x[index]["name"] = value
x[index][2] = index
end
table.sort(x,function(a,b) return (a.name < b.name)end)
for index, value in pairs(x) do
Msg(value.name)
Msg(value[2])
end
- API Detail-
No preparation required
- SCRIPT -
dofile(reaper.AZ_GetLuaInitPath())
Loading the initial settings for the Lua version of RIGDOCKS
t = {"test1","test3","test2"}
x = {}
Defining an Array
for index, value in pairs(t) do
x[index]= {}
x[index]["name"] = value
x[index][2] = index
end
Repeat the number of times for the number of elements in array (t).
Create a table for the index of array(x) that is the same as array(t),
Store the value and index of array (t) in "name" and "2", respectively.
table.sort(x,function(a,b) return (a.name < b.name)end)
Sorts the contents of an array (x) using the names of the array.
for index, value in pairs(x) do
Msg(value.name)
Msg(value[2])
end
Output array (x) to console with ForLoop