finneycanhelp finneycanhelp - 2 months ago 16
Swift Question

Swift Stable Sort?

At this time (March 28, 2015): If I want to use a stable sort in swift, I have to use

or write my own stable sort in Swift such as an insertion sort? I see in the Apple Swift docs that
is not stable.

Example of stable sort in NSMutableArray:

[array sortWithOptions:NSSortStable usingComparator:^NSComparisonResult(id obj1, id obj2) {
return [obj1 compare:obj2];

Am I missing another option that's available to me in Swift other than using Objective-C or writing my own sort?


As @Michael put it, one can "write a swift-wrapper that calls the objective-c function"