I have an NSArray of NSDictionaries which I would like to sort and remove duplicates from. The issue I am having is the NSDictionary contains two elements startYear and finishYear so I have an NSArray of Dictionary values that I would like to sort using startYear and finishYear.
The NSDictionary looks like this, They both contain string values.
starYear
finishYear
The values that are contained in both look like this -
(startYear / finishYear)
------------------------
(0 - 1999)
(1999 - 0)
(1999 - 2000)
(2001 - 2008)
(2000 - 2010)
(0 - 1999)
(0 - 2006)
should look like this -
(startYear / finishYear)
------------------------
(0 - 1999)
(1999 - 0)
(1999 - 2000)
(0 - 2006)
(2000 - 2010)
(2001 - 2008)
As you can see any repeating values have been removed. If startYear is 0 then that values is sorted by finishYear. If startYear and finishYear are avalible then its sorted into its startYear and then ordered according to finish year.
I am at a complete loss on how to even approach this, I have read up about sets etc.. But I just have no idea on how to sort according to the two elements in the NSDictionary.
I hope this is enough information to get some help, suggestions code examples anything to get me onto solving this would be greatly appreciated.