diff options
author | Robin Gareus <robin@gareus.org> | 2019-06-24 15:09:34 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-06-24 15:09:54 +0200 |
commit | 0bd6b0ee3dd8e5145697c14a8e3e5c2cd5b3fbf0 (patch) | |
tree | c16076f813599e39828d800582e4b0fb05f0dcc7 /scripts/_sort_tracks_by_name.lua | |
parent | a3f8449595601d589d50a61fad670aa8fec38f51 (diff) |
NO-OP: documentation/comments
Diffstat (limited to 'scripts/_sort_tracks_by_name.lua')
-rw-r--r-- | scripts/_sort_tracks_by_name.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/_sort_tracks_by_name.lua b/scripts/_sort_tracks_by_name.lua index 9edad9610c..36dfdc970c 100644 --- a/scripts/_sort_tracks_by_name.lua +++ b/scripts/_sort_tracks_by_name.lua @@ -7,23 +7,30 @@ ardour { function factory () return function () + -- sort compare function + -- a,b here are http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Route + -- return true if route "a" should be ordered before route "b" function tsort (a, b) return a:name() < b:name() end + -- create a sortable list of tracks local tracklist = {} for t in Session:get_tracks():iter() do table.insert(tracklist, t) end + -- sort the list using the compare function table.sort(tracklist, tsort) + -- traverse the sorted list and assign "presentation-order" to each track local pos = 1; for _, t in ipairs(tracklist) do t:set_presentation_order(pos) pos = pos + 1 end + -- drop all track references tracklist = nil collectgarbage () end end |