---
name: "lnbSortBy"
type: command
status: ok
groups: ["GUI Control - ListNBox"]
arma3_since: "2.06"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/lnbSortBy
revid: 352015
updated: 2024-02-01T23:24:06Z
---

# lnbSortBy

*Command · GUI Control - ListNBox · Arma 3 v2.06*

## Description

Sorts given multi-column ListNBox in the given column by either [lnbText](../commands/lnbText.md), [lnbValue](../commands/lnbValue.md) or [lnbData](../commands/lnbData.md) 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.

When sorting by `"VALUE"`, the rows with the same [lnbValue](../commands/lnbValue.md) will additionally be sorted by [lnbText](../commands/lnbText.md) in the order specified by the *reversedOrder* flag, text specified by `useTextRight` flag and case-sensitivity specified by `caseSensitive` flag.

> [!IMPORTANT]
> - This command supports referencing control via IDC as well, but as with any use of IDC in UI [Control](../topics/Control.md) commands, a [dialog](../commands/dialog.md) should be present, i.e. UI user interaction is created with [createDialog](../commands/createDialog.md) rather than [createDisplay](../commands/createDisplay.md).
> - As this command supports UNICODE by default, which may result in slower sorting, you can switch it off with `unicodeOff` param.

## Syntax

```sqf
[controlOrIDC, column] lnbSortBy [sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]
```

**Parameters:**

- `controlOrIDC`: [Control](../topics/Control.md) or [Number](../topics/Number.md) - the ListNBox control or its IDC
- `column`: [Number](../topics/Number.md) - column to sort (starts with 0)
- `sortByType`: [String](../topics/String.md) - (Optional, default "TEXT") one of:
  - `"TEXT"`
  - `"VALUE"`
  - `"DATA"`
- `reversedOrder`: [Boolean](../topics/Boolean.md) - (Optional, default [false](../commands/false.md)) [true](../commands/true.md) for sorting in reversed order
- `caseSensitive`: [Boolean](../topics/Boolean.md) - (Optional, default [false](../commands/false.md)) [true](../commands/true.md) for using case-sensitive comparison
- `useTextRight`: [Boolean](../topics/Boolean.md) - (Optional, default [false](../commands/false.md)) [true](../commands/true.md) to sort by [text right](../commands/lnbSetTextRight.md)
- `unicodeOff`: [Boolean](../topics/Boolean.md) - (Optional, default [false](../commands/false.md)) [true](../commands/true.md) to switch off UNICODE conversion for faster sorting

**Returns:** [Nothing](../topics/Nothing.md)

## Examples

### Example 1

```sqf
with uiNamespace do
{
    private _column = 1;
    private _lnb = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscListNBox", -1];
    _lnb ctrlSetPosition [0,0,1,1];
    _lnb ctrlCommit 0;
    lnbClear _lnb;
    { 
        _lnb lnbAddRow [format ["Row %1", _forEachIndex], _x select 0];
        _lnb lnbSetValue [[_forEachIndex, _column], _x select 1];
    } 
    forEach [["В",1], ["Я",0], ["Б",1], ["Ю",0], ["А",1]];
    [_lnb, _column] lnbSortBy ["VALUE", true, false];
};
```

## See also

[lbSortBy](../commands/lbSortBy.md) · [lnbSort](../commands/lnbSort.md) · [lnbSortByValue](../commands/lnbSortByValue.md) · [lbSort](../commands/lbSort.md) · [lbSortByValue](../commands/lbSortByValue.md) · [tvSort](../commands/tvSort.md) · [tvSortByValue](../commands/tvSortByValue.md) · [sort](../commands/sort.md)

<sub>Source: [BI Community Wiki — lnbSortBy](https://community.bistudio.com/wiki/lnbSortBy) (revision 352015).</sub>
