---
title: "sort(_:sortOrder:)"
framework: accelerate
role: symbol
role_heading: Type Method
path: "accelerate/vdsp/sort(_:sortorder:)-418g0"
---

# sort(_:sortOrder:)

Sorts a vector of double-precision values in-place.

## Declaration

```swift
static func sort<V>(_ vector: inout V, sortOrder: vDSP.SortOrder) where V : AccelerateMutableBuffer, V.Element == Double
```

## Parameters

- `vector`: The array to sort.
- `sortOrder`: The sort order.

## Discussion

Discussion The single- and double-precision sort(_:sortOrder:) functions sort an array in place. The following code sorts an array in ascending order, followed by decending order: var values: [Float] = [4.0, 8.0, 3.0, 0.0, 7.0, 5.0, 9.0, 2.0, 6.0, 1.0]

vDSP.sort(&values,           sortOrder: .ascending)

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

vDSP.sort(&values,           sortOrder: .descending)

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

## See Also

### Vector sorting functions

- [sort(_:sortOrder:)](accelerate/vdsp/sort(_:sortorder:)-wx0w.md)
- [vDSP.SortOrder](accelerate/vdsp/sortorder.md)
