TreeItem:sort( [recursive] ) method


Sorts all the subitems of the TreeItem in ascending order.

[recursive]

An optional boolean value indicating if all levels of subitems below the parent TreeItem should also be sorted (true) or only the first level (false).
If omitted, the TreeItem will sort only its first level subitems.

Return value

This function returns no value.

Example

local ui = require "ui" local win = ui.Window("TreeItem:sort() sample", 320, 220) local tree = ui.Tree(win, {Item1 = {"SubItemC", "SubItemA", "SubItemB"}, "Item2", "Item3"}, 60, 40, 200, 160) local button = ui.Button(win, "sort subitems", 120, 10) tree.items.Item1:expand() function button:onClick() tree.selected:sort() end win:show() while win.visible do ui.update() button.enabled = tree.selected ~= nil and tree.selected.count > 0 end