localizedCompare:是Apple提供的根据目前系统语言决定的排序方法,在中文简体时可以进行多音字的排序。所以只需要[stringArr sortedArrayUsingSelector:@selector(localizedCompare:)];就可以解决排序问题。
NSArray *stringArr = @[@"我们",@"我的", @"重点", @"重庆", @"三"];
NSArray *result = [stringArr sortedArrayUsingSelector:@selector(localizedCompare:)];
NSLog(@"%@", result);
NSSortDescriptor *ageSD = [NSSortDescriptor sortDescriptorWithKey:@"age" ascending:YES];//ascending:YES 代表升序 如果为NO 代表降序
NSSortDescriptor *scoreSD=[NSSortDescriptor sortDescriptorWithKey:@"score" ascending:YES];
self.datas = [[self.datas sortedArrayUsingDescriptors:@[ageSD,scoreSD]] mutableCopy];