I have a class with a contructor that with NSOrdered set as param, my secondary contructor will receive a collection and a comparator. I am not able to initiale NSOrdered as no contructors exists that converts array to NSOrderedSet
class IOSSortedSet<T>(private val list: NSOrderedSet) : SortedSet<T> {
constructor(
comparator: Comparator<in T>,
collection: Iterable<T>
) : this(NSOrderedSet(collection.sortedWith(comparator).toList())). //Incorrect
Basically the line NSOrderedSet(collection.sortedWith(comparator).toList()) is incorrect. Please help me with the correct syntax.

This question, as is the case with several others relating to how to write Kotlin/Native code for iOS, is best solved by referencing Apple's Objective-C documentation for NSOrderedSet (instead of the Swift documentation).
This shows various options for creating NSOrderedSet, and note that these are all class methods (annotated with a
+) as opposed to instance methods (annotated with a-). (Having a basic understanding of Objective-C and how to read the language can be quite helpful in this case.)Since these are class methods, in Kotlin, these can be found on the
.Companionobject ofNSOrderedSet:Since you mentioned creating an NSOrderedSet from an array, I would guess that the
orderedSetWithArraymethod might be what you're looking for.There are two variations of this method: one that takes just an array (or a List in Kotlin), and another that takes an array along with a range and boolean indicator for copying items or not.
While sometimes it can be possible to dig through the Kotlin/Native header files (at least, I haven't found an effective way to search through these yet...), in this case, the Foundation class definitions appear to be quite spread out, so I'd recommend using the Objective-C documentation as a starting point instead.