---
title: "argsort(alongAxis:descendingOrder:)"
framework: coreml
role: symbol
role_heading: Instance Method
path: "coreml/mltensor/argsort(alongaxis:descendingorder:)"
---

# argsort(alongAxis:descendingOrder:)

Returns the indices (or arguments) of a tensor that give its sorted order along the specified axis.

## Declaration

```swift
func argsort(alongAxis axis: Int = -1, descendingOrder: Bool = false) -> MLTensor
```

## Parameters

- `axis`: The axis along which to sort. The default is -1, which sorts the last axis.
- `descendingOrder`: A Boolean value that determines the sort order. The default is false which sorts from largest to least.

## Return Value

Return Value A Int32 tensor of sorted indices.

## Discussion

Discussion For example: let x = MLTensor([1.0, 3.0, 2.0]) let y = x.argSort() await y.shapedArray(of: Int32.self) // is [0, 2, 1]

## See Also

### Accessing the indicies

- [argmax()](coreml/mltensor/argmax().md)
- [argmax(alongAxis:keepRank:)](coreml/mltensor/argmax(alongaxis:keeprank:).md)
- [argmin()](coreml/mltensor/argmin().md)
- [argmin(alongAxis:keepRank:)](coreml/mltensor/argmin(alongaxis:keeprank:).md)
