<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "swift: 5.9.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftData",
  "identifier" : "/documentation/SwiftData/FetchDescriptor/init(predicate:sortBy:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftData"
    ],
    "preciseIdentifier" : "s:9SwiftData15FetchDescriptorV9predicate6sortByACyxG10Foundation9PredicateVyx_QPGSg_SayAG04SortD0VyxGGtcfc"
  },
  "title" : "init(predicate:sortBy:)"
}
-->

# init(predicate:sortBy:)

Creates a fetch descriptor with the specified predicate that, optionally,
arranges the fetched models in a particular order.

```
init(predicate: Predicate<T>? = nil, sortBy: [SortDescriptor<T>] = [])
```

## Parameters

`predicate`

The logical condition that determines whether the fetch includes a specific model in its results. The default value is `nil`.

`sortBy`

The array of sort descriptors that tell the fetch how to order its results. The default value is an empty array.

## Discussion

If you don’t specify a predicate, any fetch using this descriptor will return
all models of the associated type. If you expect the number of fetched models
to be high, use [`fetchLimit`](/documentation/SwiftData/FetchDescriptor/fetchLimit) and [`fetchOffset`](/documentation/SwiftData/FetchDescriptor/fetchOffset) to break those results into
smaller, more efficient batches.

---

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)