views:

166

answers:

1

Suppose I have a UITableViewController with an array "history" as data source. The array consists of an undefined number of NSDictionaries. Each dictionary contains the following keys: term (NSString), date (NSDate) and id (NSNumber).

I would like to map the contents of the history array according to the date values each dictionary has, i.e. I need to dynamically create sections, named and sorted according to the date values of each dictionary (the iPhone app wikipanion does this in its history view). Is there a best practice to do this? Otherwise I would just read out each date object, sort them into another dictionary, etc...

+1  A: 

Best practice is to 'group by YYYY-MM-DD' and then 'sort by YYYY-MM-DD HH:MM:SS'. So this involves some simple grouping of your dictionaries into arrays. Now that you have an array of arrays you can sort those simply by date.

St3fan
Thanks for your answer, St3fan.Could you please elaborate on how to exactly do the grouping and sorting?
ff10
Why don't you make a start with the code, add it here to your question and go from there ... ? :-)
St3fan