MutableCollection

protocol MutableCollection : Collection where Self.SubSequence : MutableCollection
  • SwifterSwift: Sort the collection based on a keypath and a compare function.

    Declaration

    Swift

    mutating func sort<T>(by keyPath: KeyPath<Element, T>, with compare: (T, T) -> Bool)

    Parameters

    path

    Key path to sort. The key path type must be Comparable.

    compare

    Comparation function that will determine the ordering.

  • SwifterSwift: Sort the collection based on a keypath and a compare function.

    Declaration

    Swift

    mutating func sort<T>(by keyPath: KeyPath<Element, T>) where T : Comparable

    Parameters

    path

    Key path to sort. The key path type must be Comparable.