{"name":"lnbSortBy","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","games":{"arma3":"2.06"},"since":"arma3 2.06","arma3_since":"2.06","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.\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]","params":[{"name":"controlOrIDC","type":"Control or Number","description":"the ListNBox control or its IDC","type_expr":"Control | Number"},{"name":"column","type":"Number","description":"column to sort (starts with 0)","type_expr":"Number"},{"name":"sortByType","type":"String","optional":true,"default":"\"TEXT\"","description":"one of:\n\n- `\"TEXT\"`\n- `\"VALUE\"`\n- `\"DATA\"`","type_expr":"String","text":"sortByType: String - (Optional, default \"TEXT\") one of:\n\n- `\"TEXT\"`\n- `\"VALUE\"`\n- `\"DATA\"`"},{"name":"reversedOrder","type":"Boolean","optional":true,"default":"false","description":"true for sorting in reversed order","type_expr":"Boolean","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","type_expr":"Boolean","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","type_expr":"Boolean","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","type_expr":"Boolean","text":"unicodeOff: Boolean - (Optional, default false) true to switch off UNICODE conversion for faster sorting"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"[controlOrIDC, column]"},"right":{"text":"[sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]"}}],"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};"]}],"see_also":["lbSortBy","lnbSort","lnbSortByValue","lbSort","lbSortByValue","tvSort","tvSortByValue","sort"]}