ios 汉字字符串数组拼音排序

ios没有提供简单的汉字拼音排序方法,在网上看到了oc方法,这里写以下对应的swift方法

 var stringCompareBlock: (String,String)->Bool = { (str1:String, str2:String) -> Bool in
var nsStr1 = str1 as NSString
var nsStr2 = str2 as NSString var encode:NSStringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(CFStringEncodings.GB_18030_2000.rawValue)) var temp1:NSString = nsStr1.stringByAddingPercentEscapesUsingEncoding(encode)!
var temp2:NSString = nsStr2.stringByAddingPercentEscapesUsingEncoding(encode)! return temp1.compare(temp2) == NSComparisonResult.OrderedAscending
}

oc的方法链接如下:

http://bbs.9ria.com/thread-230144-1-1.html

上一篇:关于git CRLF LF结尾的问题


下一篇:[题解]NOIP2018(普及组)T1标题统计(title)