I have objects which implement Сomparable protocol:
class SomeClass: Comparable {
...//comparable implementation
}
So now I can for example sort [SomeClass].
But if I want to compare arrays of such objects?
Binary operator '<' cannot be applied to two '[SomeClass]' operands
How to solve this issue?
I think you are looking for the
lexicographicallyPrecedes(_:)method ofSequence.There is also a
lexicographicallyPrecedes(_:by:)method that takes a comparison function, in case your elements aren'tComparable(or you don't want to use the conformance).