Hello everybody,
I have an NSMutableArray containing various NSDictionary. In each of the NSDictionary, I have two key-value pairs, for example: username and loginDate.
I need to sort all NSDictionary in this NSMutableArray based on loginDate and username ascending.
Just to illustrate in more detail:
NSMutableArray (index 0): NSDictionary -> username:"user1", loginDate:20 Dec 2011 NSMutableArray (index 1): NSDictionary -> username:"user2", loginDate:15 Dec 2011 NSMutableArray (index 2): NSDictionary -> username:"user3", loginDate:28 Dec 2011 NSMutableArray (index 3): NSDictionary -> username:"user4", loginDate:28 Dec 2011
After sorting, the result in the array should be:
NSMutableArray (index 0): NSDictionary -> username:"user3", loginDate:28 Dec 2011 NSMutableArray (index 1): NSDictionary -> username:"user4", loginDate:28 Dec 2011 NSMutableArray (index 2): NSDictionary -> username:"user1", loginDate:20 Dec 2011 NSMutableArray (index 3): NSDictionary -> username:"user2", loginDate:15 Dec 2011
How can i achieve this? Passed through some sortUsingComparator method, I canβt figure out how to do this.
source share