I'm developing an iOS 4 application with latest SDK and XCode 4.2.
I have a NSMutableDictionary
where keys are NSDate
and values are NSMutableString
.
When I have filled up the NSMutableDictionary I want to sort its keys but I don't know how can I do it.
I want first January dates, then February and so on.
The NSDate
key format is dd/mm/yyyy.
How can I sort those keys when NSMutableDictionary
has all its keys and values? (I'm not going to add more).
Try this code:
But note that you cannot sort a dictionary, as it is based on key-value lookups, not indexed lookups.
That's a pretty standard thing, however, you may not sort an NSDictionary - you may sort an array you get from the dictionary however.
This is what I'd do: