The block needs to return a value of type NSComparisonResult
. You are not doing that.
Try:
[points sortUsingComparator:^NSComparisonResult (id firstObject, id secondObject)
{
CGPoint firstPoint = [firstObject CGPointValue];
CGPoint secondPoint = [secondObject CGPointValue];
if (firstPoint.y > secondPoint.y) {
return NSOrderedDescending;
} else if (firstPoint.y < secondPoint.y) {
return NSOrderedAscending;
} else {
return NSOrderedSame;
}
}];
I might have the "Ascending/Descending" values backward. If you get the results in the reverse order, swap those two return values.