I am trying to sort an array NSObjects(the object has a class). The object class has several variables that I want to use to sort the objects in the array, the variables that I use for sorting are of type NSStringor NSInteger, I'm sure, sorting NSString, but for this question I hope to get help for sorting NSInteger.
This is the method that I use to sort an array of objects. He gets NSMutableArrayobjects
- (NSMutableArray *)startSortingTheArray:(NSMutableArray *)unsortedArray
{
[unsortedArray sortUsingComparator:^ NSComparisonResult(SearchResultItem *d1, SearchResultItem *d2) {
NSInteger DoorID1 = d1.doorID;
NSInteger DoorID2 = d2.doorID;
NSComparisonResult result = [DoorID1 localizedCompare:DoorID2];
if (result == NSOrderedSame) {
NSString *handel1 = d1.handel;
NSString *handel2 = d2.handel;
result = [handel1 localizedCompare:handel2];
}
I'm not sure how to compare NSInteger, I read that I can make minus each number from myself .. if the number is 0, then they are equal to + 1 / -1, etc. they are not ... but not sure if this is the best way to approach this.
Any help would be appreciated.