Понял это после просмотра другого примера с использованием пользовательского сравнения.Вот код, с которым я закончил:
@interface NSString (CustomStatusCompare)
- (NSComparisonResult)customStatusCompare:(NSString*)other;
@end
@implementation NSString (CustomStatusCompare)
- (NSComparisonResult)customStatusCompare:(NSString*)other {
NSAssert([other isKindOfClass:[NSString class]], @"Must be a NSString");
if ([self isEqual:other]) {
return NSOrderedSame;
}
else if ([self length] > 0 && [other length] > 0) {
return [self localizedCaseInsensitiveCompare:other];
}
else if ([self length] > 0 && [other length] == 0) {
return NSOrderedAscending;
}
else {
return NSOrderedDescending;
}
}
@end
NSSortDescriptor *serviceTypeDescriptor =
[[NSSortDescriptor alloc] initWithKey:@"Service"
ascending:YES
selector:@selector(localizedCaseInsensitiveCompare:)];
NSSortDescriptor *locationDescriptor =
[[NSSortDescriptor alloc] initWithKey:@"Location"
ascending:YES
selector:@selector(customStatusCompare:)]; //using custom comparison here!
NSArray *descriptors = [NSArray arrayWithObjects:locationDescriptor, nameDescriptor, nil];
self.navArray = [self.navArray sortedArrayUsingDescriptors:descriptors];
Таким образом, компаратор возвращает NSOrderedSame, если обе строки пусты ... вызывает функцию обычного сравнения, если обе строки не пусты ... если только одна строкапустой, он меняет нормальный порядок сравнения.Voila!