<!--
{
  "documentType" : "article",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/filters-and-sorting",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Filters and Sorting"
}
-->

# Filters and Sorting

Use predicates, expressions, and sort descriptors to examine elements in collections and other services.

## Topics

### Filltering

[`Predicate`](/documentation/Foundation/Predicate)

A logical condition used to test a set of input values for searching or filtering.

[`PredicateError`](/documentation/Foundation/PredicateError)

An error thrown while evaluating a predicate.

[`PredicateCodableConfiguration`](/documentation/Foundation/PredicateCodableConfiguration)

A specification of the expected types and key paths found in an archived predicate.

[`PredicateCodableKeyPathProviding`](/documentation/Foundation/PredicateCodableKeyPathProviding)

A type that provides the expected key paths found in an archived predicate.

[`PredicateExpression`](/documentation/Foundation/PredicateExpression)

A component expression that makes up part of a predicate.

[`StandardPredicateExpression`](/documentation/Foundation/StandardPredicateExpression)

A component expression that makes up part of a predicate, and that’s supported by the standard predicate type.

[`PredicateExpressions`](/documentation/Foundation/PredicateExpressions)

The expressions that make up a predicate.

[`PredicateBindings`](/documentation/Foundation/PredicateBindings)

A mapping from a predicates’s input variables to their values.

[`NSPredicate`](/documentation/Foundation/NSPredicate)

A definition of logical conditions for constraining a search for a fetch or for in-memory filtering.

[`NSExpression`](/documentation/Foundation/NSExpression)

An expression for use in a comparison predicate.

[`NSComparisonPredicate`](/documentation/Foundation/NSComparisonPredicate)

A specialized predicate for comparing expressions.

[`NSCompoundPredicate`](/documentation/Foundation/NSCompoundPredicate)

A specialized predicate that evaluates logical combinations of other predicates.

### Sorting

[`NSSortDescriptor`](/documentation/Foundation/NSSortDescriptor)

An immutable description of how to order a collection of objects according to a property common to all the objects.

[`ComparisonResult`](/documentation/Foundation/ComparisonResult)

Constants that indicate sort order.

[`SortDescriptor`](/documentation/Foundation/SortDescriptor)

A serializable description of how to sort numerics and strings.

[`SortComparator`](/documentation/Foundation/SortComparator)

A comparison algorithm for a specified type.

[`ComparableComparator`](/documentation/Foundation/ComparableComparator)

A comparator that compares types according to their conformance to the comparable protocol.

[`KeyPathComparator`](/documentation/Foundation/KeyPathComparator)

A comparator that uses another sort comparator to provide the comparison of values at a key path.

[`SortOrder`](/documentation/Foundation/SortOrder)

The orderings that you can perform sorts with.



---

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)