> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# sort()

<span id="atoti.array.sort" />

> atoti.array.sort(<br />
>     *measure*: VariableMeasureConvertible,<br />
>     /,<br />
>     \*,<br />
>     *ascending*: [bool](https://docs.python.org/3/library/functions.html#bool) = `True`,<br />
> ) → MeasureDefinition

Return an array measure with the elements of the passed array measure sorted.

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> pnl_table = session.read_csv(
...     TEST_RESOURCES_PATH / "csv" / "pnl.csv",
...     array_separator=";",
...     keys={"Continent", "Country"},
...     table_name="PnL",
... )
>>> cube = session.create_cube(pnl_table)
>>> l, m = cube.levels, cube.measures
>>> m["Ascending sort"] = tt.array.sort(m["PnL.SUM"])
>>> m["Descending sort"] = tt.array.sort(m["PnL.SUM"], ascending=False)
>>> cube.query(m["PnL.SUM"], m["Ascending sort"], m["Descending sort"])
                          PnL.SUM                              Ascending sort                           Descending sort
0  doubleVector[10]{-20.163, ...}  doubleVector[10]{-110.09900000000002, ...}  doubleVector[10]{9.259999999999998, ...}
```

### Parameters

<h4 id="atoti.array.sort.measure">
  *measure*
</h4>

> VariableMeasureConvertible

<h4 id="atoti.array.sort.ascending">
  *ascending*
</h4>

> [bool](https://docs.python.org/3/library/functions.html#bool)
