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 to key.

  • If order is ‘descending’, sort such that values are non-increasing according to key.

  • x (Union[Variable, DataArray, Dataset]) – Data to be sorted.

  • key (Union[str, Variable]) – Either a 1D variable sort key or a dimension label.

  • order (Optional[str], default: 'ascending') – Sorting order. Valid options are ‘ascending’ and ‘descending’. Default is ‘ascending’.


If the key is invalid, e.g., if it does not have exactly one dimension, or if its dtype is not sortable.


Union[Variable, DataArray, Dataset] – The sorted equivalent of the input.