<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vDSP_vsort",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@vDSP_vsort"
  },
  "title" : "vDSP_vsort"
}
-->

# vDSP_vsort

Performs an in-place sort of a single-precision vector.

```
extern void vDSP_vsort(float *__C, vDSP_Length __N, int __Order);
```

## Parameters

`__C`

The vector that the function sorts in-place.

`__N`

The number of elements in the vector.

`__Order`

A value that specifies the sort order. Pass `1` to specify ascending order, or `-1` for descending order.

## Discussion

The following code sorts an array in ascending order, followed by decending order:

```swift
    var values: [Float] = [4.0, 8.0, 3.0, 0.0, 7.0, 5.0, 9.0, 2.0, 6.0, 1.0]

    let n = vDSP_Length(values.count)
    
    vDSP_vsort(&values, n, 1)

    // Prints "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]".
    print(values)

    vDSP_vsort(&values, n, -1)

    // Prints "[9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0]".
    print(values)
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)