top of page
- Script Code -

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

- Warm Up -

No preparation required

- Script Detail -

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

- API LINK -

Beginner

AZ_tableSort(name)

Sort by elements in an array

01_BRONZE_ss_edited.png
01_SILVER_edited_edited.png
03_GOLD_edited_edited.png
bottom of page