简体   繁体   中英

sort NSArray alphabetically, but local language should be first and then all other

I need to sort my array sectionIndexTitlesForTableView on next rules: first sort using local alphabetic (german, france or some else - current user interface) and then english sort and at the end all other symbols in section #. I'm tried to make this using sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:) method, but they don't help (the sort english first and then local strings). How to do this?

I'm not sure any of the standard comparators will do what you're asking for, but you can always write your own.

(And if you don't want to have to make a category on NSString for implementing your own comparison selector, you can always use -[NSArray sortedArrayUsingComparator:] which lets you pass a block.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM