List:sort(direction) method


Sort the List items.

Parameters

direction

A string that specifies the sort direction :

  • "none" : No sorting.
  • "ascend" : the List will be sorted in alphabetic order
  • "descend" : the List will be sorted in inverse alphabetic order.
  • Return value

    This function returns no value.

    Example

    local ui = require "ui" local win = ui.Window("List.sort() constructor sample", "fixed", 320, 240) local button = ui.Button(win, "Sort list", 130, 50) local list = ui.List(win, {"ABC", "A", "ABCD"}, 120, 80) local mode = "descend" function button:onClick() win:status("List sorted in "..mode.."ing order") list:sort(mode) mode = mode == "descend" and "ascend" or "descend" end win:status("List is not sorted") -- show the Window win:show() while win.visible do ui.update() end