此时(2015年3月28日):如果我想在swift中使用稳定排序,我必须使用 NSArray 和 sortWithOptions 或在Swift中编写我自己的稳定排序,例如插入排序 ?我在 Apple Swift docs 中看到已排序不稳定。
At this time (March 28, 2015): If I want to use a stable sort in swift, I have to use NSArray and sortWithOptions or write my own stable sort in Swift such as an insertion sort? I see in the Apple Swift docs that sorted is not stable.
NSMutableArray中稳定排序的示例:
[array sortWithOptions:NSSortStable usingComparator:^NSComparisonResult(id obj1, id obj2) { return [obj1 compare:obj2]; }];我错过了除了使用Objective-C或编写自己的Swift之外我可以使用的另一个选项排序?
Am I missing another option that's available to me in Swift other than using Objective-C or writing my own sort?
推荐答案正如@Michael所说,人们可以编写一个调用objective-c函数的swift-wrapper
As @Michael put it, one can "write a swift-wrapper that calls the objective-c function"