排序Unicode字符串 [英] Sorting Unicode strings

查看:86
本文介绍了排序Unicode字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iPhone应用程序中对Unicode(外国)字符串进行排序?

How do I sort Unicode (foreign) strings in my iPhone application?

推荐答案

感谢您帮助我。

localizedCaseInsensitiveCompare

此API将进行排序关于本地化。否则,不同语言的字符串将被视为unicode字符串,并且比较失败。

this API will do the sorting with respect to localization. Otherwise strings of different languages will be treated as a unicode strings and comparison fails.

以下是解决方案:

NSComparisonResult sortLocationsForStr(NSString* str1, NSString* str2, void *context)
{
    return [str1 localizedCaseInsensitiveCompare:str2];
}

[myArrayToSort sortUsingFunction:sortLocationsForStr context:nil];

这篇关于排序Unicode字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆