> ## 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.

# NaturalOrder

<span id="atoti.NaturalOrder" />

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

[Natural order](https://en.wikipedia.org/wiki/Natural_sort_order).

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> df = pd.DataFrame(
...     {
...         "File": ["file10", "file2", "file1"],
...         "Quantity": [10, 2, 1],
...     }
... )
>>> table = session.read_pandas(df, table_name="String")
>>> cube = session.create_cube(table)
>>> l, m = cube.levels, cube.measures
>>> l["File"].order = tt.NaturalOrder()
```

Digit sequences in strings are compared by their numeric value rather than character by character:

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> cube.query(m["Quantity.SUM"], levels=[l["File"]])
       Quantity.SUM
File
file1             1
file2             2
file10           10
>>> l["File"].order = tt.NaturalOrder(ascending=False)
>>> cube.query(m["Quantity.SUM"], levels=[l["File"]])
       Quantity.SUM
File
file10           10
file2             2
file1             1
```

<Callout icon="link">
  **See also**:
  All the available [`orders`](./atoti.order#module-atoti.order).
</Callout>

### Attributes

<h4 id="atoti.NaturalOrder.ascending">
  *ascending*
</h4>

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