最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Swift稳定排序?

SEO心得admin145浏览0评论
本文介绍了Swift稳定排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

此时(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"

发布评论

评论列表(0)

  1. 暂无评论