---
name: "BIS_fnc_initListNBoxSorting"
type: function
status: ok
groups: ["GUI"]
arma3_since: "1.56"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/BIS_fnc_initListNBoxSorting
revid: 349789
updated: 2023-11-20T22:10:14Z
---

# BIS_fnc_initListNBoxSorting

*Function · GUI · Arma 3 v1.56*

## Description

Automatically creates buttons and sets them up so they can be used to sort a CT_LISTNBOX. The buttons will automatically be resized to fit the column width of **ctrlFilter**.

By default, the **ctrlContent** columns are sorted by [lnbText](../commands/lnbText.md) (using [lnbSort](../commands/lnbSort.md)). If a specific column should be sorted by [lnbValue](../commands/lnbValue.md) (using [lnbSortByValue](../commands/lnbSortByValue.md)) instead, then something needs to be set in the data of the corresponding **ctrlFilter** column (literally *something*, the condition in the source code is `(_ctrlFilter lnbData [0, _i]) != ""`).

Regarding **ctrlFilter**:
- The position and size of this control define where the buttons for sorting are created, thus it should be placed above **ctrlContent** and its columns should have the same size as the columns of **ctrlContent**.
- The text set in the columns is displayed as text for the buttons (the buttons are actually transparent).
- The control can also be part of a CT_CONTROLS_GROUP. If that is the case, the buttons will be created as children of that group.
- To keep a uniform style between vanilla and custom controls it is recommended to create a background with CT_STATIC behind **ctrlFilter** with `colorBackground[] = { 0, 0, 0, 1 };`.
See CT_LISTNBOX#BIS_fnc_initListNBoxSorting Example for a full example including a config.

## Syntax

```sqf
[ctrlFilter, ctrlContent, columnIndexes, idc] call BIS_fnc_initListNBoxSorting
```

**Parameters:**

- `ctrlFilter`: [Control](../topics/Control.md) - dummy CT_LISTNBOX control used for setting up the filter.
- `ctrlContent`: [Control](../topics/Control.md) - the CT_LISTNBOX which actually contains the sortable content.
- `columnIndexes`: [Array](../topics/Array.md) of [Number](../topics/Number.md)s - (Optional, default: []) these are the column indexes of *ctrlContent* which should be sortable. An empty array means all columns are sortable.
- `idc`: [Number](../topics/Number.md) - (Optional, default: 200) used to assign IDCs to the buttons created by this function. The first button has **idc**, the second button has **idc** + 1 and so on.

**Returns:** [Boolean](../topics/Boolean.md) - [true](../commands/true.md) on success, otherwise [false](../commands/false.md)

## Examples

### Example 1

```sqf
[_lnbFilter, _lnbContent, [0,1,2,3]] call BIS_fnc_initListNBoxSorting;
```

## See also

[BIS_fnc_initSliderValue](../functions/BIS_fnc_initSliderValue.md)

<sub>Source: [BI Community Wiki — BIS fnc initListNBoxSorting](https://community.bistudio.com/wiki/BIS_fnc_initListNBoxSorting) (revision 349789).</sub>
