I'm sorting an array like this:
NSArray *temp = [array sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
int first = [[a valueForKey:@"id"] intValue];
int second = [[b valueForKey:@"id"]intValue];
if (first > second) return NSOrderedAscending;
if (first < second) return NSOrderedDescending;
return NSOrderedSame;
}];
return [temp mutableCopy];
Works perfectly but now I want to add a check to see if, for example, a's value for key is equal to a certain value, always keep it at the top of the array, no matter what the "id" value is. Is it possible to do this using the comparator?