---
title: "init(filter:sort:order:animation:sectionBy:)"
framework: SwiftData
role: symbol
role_heading: Initializer
platforms: [iOS 27.0+, iPadOS 27.0+, Mac Catalyst 27.0+, macOS 27.0+, tvOS 27.0+, visionOS 27.0+, watchOS 27.0+]
path: "swiftdata/query/init(filter:sort:order:animation:sectionby:)-39v3n"
---

# init(filter:sort:order:animation:sectionBy:)

Creates a sectioned query sorted by an optional key path, grouped by a required optional-String key path.

## Declaration

```swift
@MainActor @preconcurrency init<Value>(filter: Predicate<Element>? = nil, sort keyPath: KeyPath<Element, Value?>, order: SortOrder = .forward, animation: Animation, sectionBy sectionKeyPath: KeyPath<Element, String?>) where Result == SectionedResults<Element, String>, Value : Comparable
```
