---
title: sortDescriptors
framework: cloudkit
role: symbol
role_heading: Instance Property
path: cloudkit/ckquery/sortdescriptors
---

# sortDescriptors

The sort descriptors for organizing the query’s results.

## Declaration

```swift
var sortDescriptors: [NSSortDescriptor]? { get set }
```

## Discussion

Discussion You can add sort descriptors to a query and change them later as necessary. Each sort descriptor contains a field name of the intended record type and information about whether to sort values in that field in ascending or descending order. The default value of this property is nil, which means that records return in an indeterminate order. The order of the items in the array defines the order that CloudKit applies the sort descriptors to the results. In other words, CloudKit applies the first sort descriptor in the array, then the second sort descriptor, if necessary, then the third, and so on.

## See Also

### Accessing the Query Parameters

- [recordType](cloudkit/ckquery/recordtype-6ajii.md)
- [predicate](cloudkit/ckquery/predicate.md)
