SortDescriptor
public struct SortDescriptor
A SortDescriptor
stores a property name 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 name of the property which the sort descriptor orders results by.
Declaration
Swift
public let property: String
-
Whether the descriptor sorts in ascending or descending order.
Declaration
Swift
public let ascending: Bool
-
Initializes a sort descriptor with the given property and sort order values.
Declaration
Swift
public init(property: String, ascending: Bool = true)
Parameters
property
The name of 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
-
Returns a human-readable description of the sort descriptor.
Declaration
Swift
public var description: String
-
Creates a
SortDescriptor
from aUnicodeScalarLiteralType
.Declaration
Swift
public init(unicodeScalarLiteral value: UnicodeScalarLiteralType)
Parameters
unicodeScalarLiteral
Property name literal.
-
StringLiteralType
. Required forStringLiteralConvertible
conformance.Declaration
Swift
public typealias UnicodeScalarLiteralType = StringLiteralType
-
StringLiteralType
. Required forStringLiteralConvertible
conformance.Declaration
Swift
public typealias ExtendedGraphemeClusterLiteralType = StringLiteralType
-
Creates a
SortDescriptor
from anExtendedGraphemeClusterLiteralType
.Declaration
Swift
public init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterLiteralType)
Parameters
extendedGraphemeClusterLiteral
Property name literal.
-
Creates a
SortDescriptor
from aStringLiteralType
.Declaration
Swift
public init(stringLiteral value: StringLiteralType)
Parameters
stringLiteral
Property name literal.