top of page

12

Beginner

AZ_tableSort(name)

配列内の要素を基準に並び替える

RANK

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

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


  • 配列(t)の要素数だけ繰り返す。

  • 配列(x)の、配列(t)と同値のインデックスにテーブルを作成し、

  • 「name」と「2」にそれぞれ配列(t)の値とインデックスを格納する。


table.sort(x,function(a,b) return (a.name < b.name)end)


  • 配列(x)のnameを利用して配列内のソートを行う。


for index, value in pairs(x) do

Msg(value.name)

Msg(value[2])

end


  • 配列(x)をForLoopでコンソールに出力

To use the API, you need to sign up for a plan.

Download the dedicated API

need to do it.

*SILVER is scheduled to be released in May.

準備の必要はありません

- Script Code -
- Script Image -
- Warm Up -
- Script Detail -
- API -

LUA

​ReaScript File Download 👇

* A dedicated API is required to run this

- Script Image -
bottom of page