restrict_sort_to

restrict_sort_to only allows sorting on specified table columns. This can be useful to prevent users from accidentally performing expensive sort operations as they interact with tables in the UI.

Syntax

Parameters

ParameterTypeDescription
colsUnion[str, Sequence[str]]

The column(s) on which sorting is allowed.

Returns

A new table that only allows sorting on the columns specified in the cols argument.

Examples

The table can be sorted by the columns Ticker or Exchange with success:

An attempt to sort a column outside the arguments of restrict_sort_to will result in an error:

An error message stating that sorting is not allowed on this table