Search code examples
sortingnsarraynsdateuid

Sorting NSDate then associating it with its original unique ID


I have two arrays, one that is made up of NSDates and one that's made up of ints that I use as a unique identifier.

I sort the NSDate array using sortedArrayUsingSelector:@selector(compare:) which sorts them perfectly, the problem is I need to associate those dates back to their original UID (the other NSArray).

Is there a simple way to do this or do I have to do some for/if statements?


Solution

  • Couldn't you associate the two arrays in one NSDictionary? It would then be ok for you to sort them the way you want.