SortDescriptor

public struct SortDescriptor

A SortDescriptor stores a key path and a sort order for use with sorted(sortDescriptors:). It is similar to NSSortDescriptor, but supports only the subset of functionality which can be efficiently run by Realm’s query engine.

  • The key path which the sort descriptor orders results by.

    Declaration

    Swift

    public let keyPath: String
  • Whether this descriptor sorts in ascending or descending order.

    Declaration

    Swift

    public let ascending: Bool
  • Creates a sort descriptor with the given key path and sort order values.

    Declaration

    Swift

    public init(keyPath: String, ascending: Bool = true)

    Parameters

    keyPath

    The key path which the sort descriptor orders results by.

    ascending

    Whether the descriptor sorts in ascending or descending order.

  • Creates a sort descriptor with the given property and sort order values.

    Declaration

    Swift

    public init(property: String, ascending: Bool = true)

    Parameters

    property

    The property which the sort descriptor orders results by.

    ascending

    Whether the descriptor sorts in ascending or descending order.

  • Returns a copy of the sort descriptor with the sort order reversed.

    Declaration

    Swift

    public func reversed() -> SortDescriptor
  • The key path which the sort descriptor orders results by.

    Declaration

    Swift

    public var property: String
  • A human-readable description of the sort descriptor.

    Declaration

    Swift

    public var description: String
  • Returns whether the two sort descriptors are equal.

    Declaration

    Swift

    public static func == (lhs: SortDescriptor, rhs: SortDescriptor) -> Bool
  • Creates a SortDescriptor out of a Unicode scalar literal.

    Declaration

    Swift

    public init(unicodeScalarLiteral value: UnicodeScalarLiteralType)

    Parameters

    unicodeScalarLiteral

    Property name literal.

  • Creates a SortDescriptor out of a character literal.

    Declaration

    Swift

    public init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterLiteralType)

    Parameters

    extendedGraphemeClusterLiteral

    Property name literal.

  • Creates a SortDescriptor out of a string literal.

    Declaration

    Swift

    public init(stringLiteral value: StringLiteralType)

    Parameters

    stringLiteral

    Property name literal.