How to sort this kind of case?
- I have a
NSMutableArray. - My
NSMutableArraycan have an object orNSMutableDictionary. - My
NSMutableDictionaryonly has 1 object (an object as its object and a string as its key) - Both object is the same and has attribute
name
Now, what I’m struggle with is I want to sort the NSMutableArray based on the dictionary key and the object’s name? (let’s just ignore the object that is added to NSMutableArray)
Bunch of thanks to person can give me idea how to solve this case!
Add your
NSMutableArrayto a custom subclass of NSObject and sort using a custom NSComparator, like so:Do note that this is untested and that you’ll need to fill in the bodies of the if and else statements. The comment by the else clause is just how I code and you can eliminate it if it doesn’t conform to your taste.