{"name":"lbSortBy","operator":null,"title":"lbSortBy","type":"command","url":"https://community.bistudio.com/wiki/lbSortBy","revid":310351,"updated":"2022-05-05T17:24:12Z","groups":["GUI Control - ListBox"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"2.06"}],"since":{"game":"arma3","name":"Arma 3","version":"2.06"},"arma3_since":"2.06","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Sorts given ListBox by either lbText, lbValue or lbData in normal or reversed order, using case-sensitive or case-insensitive comparison. This command supports UNICODE characters.\nWhen sorting by `\"VALUE\"`, the rows with the same lbValue will additionally be sorted by lbText in the order specified by `reversedOrder` flag, text specified by `useTextRight` flag and case-sensitivity specified by `caseSensitive` flag.\n\n> [!IMPORTANT]\n> - This command supports referencing control via IDC as well, but as with any use of IDC in UI Control commands, a dialog should be present, i.e. UI user interaction is created with createDialog rather than createDisplay.\n> - As this command supports UNICODE by default, which may result in slower sorting, you can switch it off with `unicodeOff` param.","syntaxes":[{"syntax":"controlOrIDC lbSortBy [sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]","since":null,"effect":null,"exec":null,"params":[{"name":"controlOrIDC","type":"Control or Number","optional":false,"default":null,"description":"the ListBox control or its IDC","types":["Control","Number"],"since":null,"text":"controlOrIDC: Control or Number - the ListBox control or its IDC"},{"name":"sortByType","type":"String","optional":true,"default":"\"TEXT\"","description":"one of:\n- `\"TEXT\"`\n- `\"VALUE\"`\n- `\"DATA\"`","types":["String"],"since":null,"text":"sortByType: String - (Optional, default \"TEXT\") one of:\n- `\"TEXT\"`\n- `\"VALUE\"`\n- `\"DATA\"`"},{"name":"reversedOrder","type":"Boolean","optional":true,"default":"false","description":"true for sorting in reversed order","types":["Boolean"],"since":null,"text":"reversedOrder: Boolean - (Optional, default false) true for sorting in reversed order"},{"name":"caseSensitive","type":"Boolean","optional":true,"default":"false","description":"true for using case-sensitive comparison","types":["Boolean"],"since":null,"text":"caseSensitive: Boolean - (Optional, default false) true for using case-sensitive comparison"},{"name":"useTextRight","type":"Boolean","optional":true,"default":"false","description":"true to sort by text right","types":["Boolean"],"since":null,"text":"useTextRight: Boolean - (Optional, default false) true to sort by text right"},{"name":"unicodeOff","type":"Boolean","optional":true,"default":"false","description":"true to switch off UNICODE conversion for faster sorting","types":["Boolean"],"since":null,"text":"unicodeOff: Boolean - (Optional, default false) true to switch off UNICODE conversion for faster sorting"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"controlOrIDC","types":["Control","Number"]},"right":{"text":"[sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]","types":["Array"]}}],"examples":[{"text":"```sqf\nwith uiNamespace do\n{\n    private _lb = findDisplay 46 createDisplay \"RscDisplayEmpty\" ctrlCreate [\"RscListBox\", -1];\n    _lb ctrlSetPosition [0,0,1,1];\n    _lb ctrlCommit 0;\n    lbClear _lb;\n    {\n        _lb lbAdd (_x select 0);\n        _lb lbSetValue [_forEachIndex, _x select 1];\n    }\n    forEach [[\"В\",1], [\"Я\",0], [\"Б\",1], [\"Ю\",0], [\"А\",1]];\n    _lb lbSortBy [\"VALUE\", false, false];\n};\n```","code":["with uiNamespace do\n{\n\tprivate _lb = findDisplay 46 createDisplay \"RscDisplayEmpty\" ctrlCreate [\"RscListBox\", -1];\n\t_lb ctrlSetPosition [0,0,1,1];\n\t_lb ctrlCommit 0;\n\tlbClear _lb;\n\t{\n\t\t_lb lbAdd (_x select 0);\n\t\t_lb lbSetValue [_forEachIndex, _x select 1];\n\t}\n\tforEach [[\"В\",1], [\"Я\",0], [\"Б\",1], [\"Ю\",0], [\"А\",1]];\n\t_lb lbSortBy [\"VALUE\", false, false];\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["lnbSortBy","lnbSort","lnbSortByValue","lbSort","lbSortByValue","tvSort","tvSortByValue","sort"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: GUI Control - ListBox","Introduced with Arma 3 version 2.06","Scripting Commands"]}