Returns a Boolean value indicating whether the sequence precedes another sequence in a lexicographical (dictionary) ordering, using the given predicate to compare elements.
SDK
- Xcode 11.0+
Framework
- Swift Standard Library
Declaration
Parameters
other
A sequence to compare to this sequence.
areInIncreasingOrder
A predicate that returns
true
if its first argument should be ordered before its second argument; otherwise,false
.
Return Value
true
if this sequence precedes other
in a dictionary ordering as ordered by are
; otherwise, false
.
Discussion
The predicate must be a strict weak ordering over the elements. That is, for any elements a
, b
, and c
, the following conditions must hold:
Note
This method implements the mathematical notion of lexicographical ordering, which has no connection to Unicode. If you are sorting strings to present to the end user, use String
APIs that perform localized comparison instead.
Complexity: O(m), where m is the lesser of the length of the sequence and the length of other
.
are
is alwaysIn Increasing Order(a, a) false
. (Irreflexivity)If
are
andIn Increasing Order(a, b) are
are bothIn Increasing Order(b, c) true
, thenare
is alsoIn Increasing Order(a, c) true
. (Transitive comparability)Two elements are incomparable if neither is ordered before the other according to the predicate. If
a
andb
are incomparable, andb
andc
are incomparable, thena
andc
are also incomparable. (Transitive incomparability)