我正在使用以下代码
对NSDiction的NSArray进行排序NSArray *getIndexArray = [nicknamesCombinedArray copy];
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"MANUFACTURER" ascending:YES];
NSDictionary *sortedGetIndexArray = [getIndexArray sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]];
唯一的问题是,当它排序时,如果单词是全部CAPS,那么它就像这样排序
JESS
Jack
Jelly
Job
我希望它在哪里
Jack
Jelly
JESS
Job
答案 0 :(得分:3)
试试这段代码..
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"MANUFACTURER" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];