{"name":"lnbSortBy","operator":null,"title":"lnbSortBy","type":"command","url":"https://community.bistudio.com/wiki/lnbSortBy","revid":352015,"updated":"2024-02-01T23:24:06Z","groups":["GUI Control - ListNBox"],"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 multi-column ListNBox in the given column by either lnbText, lnbValue or lnbData in normal or reversed order, using case-sensitive or case-insensitive comparison. Unlike the older **lnbSortXXX** commands, this command supports UNICODE characters out of the box.\n\nWhen sorting by `\"VALUE\"`, the rows with the same lnbValue will additionally be sorted by lnbText in the order specified by the *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, column] lnbSortBy [sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]","since":null,"effect":null,"exec":null,"params":[{"name":"controlOrIDC","type":"Control or Number","optional":false,"default":null,"description":"the ListNBox control or its IDC","types":["Control","Number"],"since":null,"text":"controlOrIDC: Control or Number - the ListNBox control or its IDC"},{"name":"column","type":"Number","optional":false,"default":null,"description":"column to sort (starts with 0)","types":["Number"],"since":null,"text":"column: Number - column to sort (starts with 0)"},{"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, column]","types":["Array"]},"right":{"text":"[sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]","types":["Array"]}}],"examples":[{"text":"```sqf\nwith uiNamespace do\n{\n    private _column = 1;\n    private _lnb = findDisplay 46 createDisplay \"RscDisplayEmpty\" ctrlCreate [\"RscListNBox\", -1];\n    _lnb ctrlSetPosition [0,0,1,1];\n    _lnb ctrlCommit 0;\n    lnbClear _lnb;\n    { \n        _lnb lnbAddRow [format [\"Row %1\", _forEachIndex], _x select 0];\n        _lnb lnbSetValue [[_forEachIndex, _column], _x select 1];\n    } \n    forEach [[\"В\",1], [\"Я\",0], [\"Б\",1], [\"Ю\",0], [\"А\",1]];\n    [_lnb, _column] lnbSortBy [\"VALUE\", true, false];\n};\n```","code":["with uiNamespace do\n{\n\tprivate _column = 1;\n\tprivate _lnb = findDisplay 46 createDisplay \"RscDisplayEmpty\" ctrlCreate [\"RscListNBox\", -1];\n\t_lnb ctrlSetPosition [0,0,1,1];\n\t_lnb ctrlCommit 0;\n\tlnbClear _lnb;\n\t{ \n\t\t_lnb lnbAddRow [format [\"Row %1\", _forEachIndex], _x select 0];\n\t\t_lnb lnbSetValue [[_forEachIndex, _column], _x select 1];\n\t} \n\tforEach [[\"В\",1], [\"Я\",0], [\"Б\",1], [\"Ю\",0], [\"А\",1]];\n\t[_lnb, _column] lnbSortBy [\"VALUE\", true, false];\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["lbSortBy","lnbSort","lnbSortByValue","lbSort","lbSortByValue","tvSort","tvSortByValue","sort"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: GUI Control - ListNBox","Introduced with Arma 3 version 2.06","Scripting Commands"]}