scipp.sort#
- scipp.sort(x, key, order='ascending')#
Sort variable along a dimension by a sort key or dimension label.
If
order
is ‘ascending’, sort such that values are non-decreasing according tokey
.If
order
is ‘descending’, sort such that values are non-increasing according tokey
.
- Parameters:
x (
scipp.typing.VariableLike
) – Data to be sorted.key (
str
|Variable
) – Either a 1D variable sort key or a dimension label.order (
Literal
['ascending'
,'descending'
], default:'ascending'
) – Sorting order.
- Returns:
scipp.typing.VariableLike
– The sorted equivalent of the input with the same type.- Raises:
scipp.DimensionError – If the key is a Variable that does not have exactly 1 dimension.