Hi all,
To sort an mantle array containing mantle model as object ,You can easily sort by multiple keys by adding more than one to the array. Using custom comparator-methods is possible as well.
NSSortDescriptor *sortDescriptor;
sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"departureTime"
ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
//busses is a temporary array used to hold sorted array
busses = [self.tripArray.data.oneWay.buses sortedArrayUsingDescriptors:sortDescriptors];
[self.ticketsTableView reloadData];
In busses array , mantle model contain key departureTime and in above code we are sorting mantle array in ascending order
0 Comment(s)