Contents

sortBy

The sort descriptors that tell the fetch how to order its results.

Declaration

var sortBy: [SortDescriptor<T>]

Discussion

Use this property to specify how to arrange the collection of models that a fetch returns. For example, if your app defines a Person model, you may want to sort by the surname attribute, then by the firstName attribute. The fetch applies the sort descriptors in the same order as they appear in the array.

The default value is the array you specify when calling init(predicate:sortBy:).

See Also

Constraining the fetch