So this is a rather basic question regarding the best way to sort an NSMutableArray of custom objects.
I have a an NSMutableArray of custom
This little snippet worked great for me:
[students sortUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]];
NSSortDescriptorss make this really simple. With NSMutableArray you can sort the existing array using sortUsingDescriptors: and with immutable arrays you create a new array using sortedArrayUsingDescriptors:
//This will sort by stringProperty ascending, then dateProperty ascending
[mutable_array sortUsingDescriptors:
@[
[NSSortDescriptor sortDescriptorWithKey:@"stringProperty" ascending:YES],
[NSSortDescriptor sortDescriptorWithKey:@"dateProperty" ascending:YES]
]];