Returns a Boolean value indicating whether the sequence precedes another sequence in a lexicographical (dictionary) ordering, using the less-than operator (<
) to compare elements.
SDK
- Xcode 9.0+
Framework
- Swift Standard Library
Declaration
Parameters
other
A sequence to compare to this sequence.
Return Value
true
if this sequence precedes other
in a dictionary ordering; otherwise, false
.
Discussion
This example uses the lexicographically
method to test which array of integers comes first in a lexicographical ordering.
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.
Complexity: O(m), where m is the lesser of the length of the sequence and the length of other
.