diff --git a/unyt/array.py b/unyt/array.py index 9e4ef409..6cd924cc 100644 --- a/unyt/array.py +++ b/unyt/array.py @@ -1099,6 +1099,24 @@ def to_ndarray(self): """ return np.array(self) + def argsort(self, axis=-1, kind='quicksort', order=None): + """ + Returns the indices that would sort the array. + + See the documentation of ndarray.argsort for details about the keyword + arguments. + + Example + ------- + >>> from unyt import km + >>> data = [3, 8, 7]*km + >>> print(np.argsort(data)) + [0 2 1] + >>> print(data.argsort()) + [0 2 1] + """ + return self.view(np.ndarray).argsort(axis, kind, order) + @classmethod def from_astropy(cls, arr, unit_registry=None): """