summaryrefslogtreecommitdiff
path: root/scripts/_sort_tracks_by_name.lua
blob: 9edad9610cbdad3b5e661f83636b41d65ebd556c (plain)
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
ardour {
	["type"] = "EditorAction",
	name = "Track Sort",
	author = "Ardour Lua Taskforce",
	description = [[Sort tracks alphabetically by name]]
}

function factory () return function ()

	function tsort (a, b)
		return a:name() < b:name()
	end

	local tracklist = {}
	for t in Session:get_tracks():iter() do
		table.insert(tracklist, t)
	end

	table.sort(tracklist, tsort)

	local pos = 1;
	for _, t in ipairs(tracklist) do
		t:set_presentation_order(pos)
		pos = pos + 1
	end

	tracklist = nil
	collectgarbage ()
end end