I have an array containing custom objects with a property named seat. Seat can have values 1A, 1D , 1C , 1k , 2A, 2k, 2D, 2C.
Now these can be arranged in any order, and I want to sort them according to class, however the sorting only accounts for the seats numeric value and not A, C, D,or K.
I want the order to be 1A,1C,1D,1K and so on.
This is what I have implemented in the SeatDO object:
-(NSComparisonResult) compareBySeatNumber:(SeatDO*)other {
NSComparisonResult result = NSOrderedSame;
NSInteger seatNumber = [self.seat integerValue];
NSInteger otherSeatNumber = [other.seat integerValue];
if (seatNumber > otherSeatNumber) {
result = NSOrderedDescending;
} else if (seatNumber < otherSeatNumber) {
result = NSOrderedAscending;
}
return result;
}
How do I make it consider the letters as well..?