Skip to content

Instance MethodSwift

sorted(using:)

iOS 15.0+ iPadOS 15.0+ Mac Catalyst 15.0+ macOS 12.0+ tvOS 15.0+ watchOS 8.0+
Returns the elements of the sequence, sorted using the given comparator to compare elements.
func sorted<Comparator>(using comparator: Comparator) -> [Self.Element] where Comparator : SortComparator, Self.Element == Comparator.Compared

Parameters

comparator

The comparator to use in ordering elements

Return Value

An array of the elements sorted using comparator.