title: Sort array with custom object by date
body: <p>I have an NSArray that contains custom Object (ItemThread) and I have to order this array using a property of these objects (a Date but is a NSString). The item to order are into an array called  "threadList" that contains my custom data (ItemThread). So I try to use:</p>
  
  <pre><code> NSSortDescriptor *sortDescriptor;
   sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"detail" ascending:NO];     
   NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
   NSArray *sortedArray = [threadList sortedArrayUsingDescriptors:sortDescriptors];
  </code></pre>
  
  <p>But it doesn't work because the property <code>detail</code> is a date but not an NSDate, is an NSString. Do you have solutions?</p>
  
  <p>Or I have tried to use </p>
  
  <pre><code> NSMutableArray *threadDateArray = [[NSMutableArray alloc] init];
   for (int i = 0; i&lt;threadList.count; i++) {
         ItemThread *_thr = [threadList objectAtIndex:i];
         [threadDateArray addObject:_thr.detail];
   }
   NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
   [dateFormatter setDateFormat:@"dd/MM/yyyy HH:mm"];
   [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
  
    NSMutableArray *dateArray = [NSMutableArray array];
    for (NSString *dateString in threadDateArray) {
         NSDate *date = [dateFormatter dateFromString:dateString];
         [dateArray addObject:date];
    }
    NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"self" ascending:NO];
    NSArray *descriptors=[NSArray arrayWithObject: descriptor];
    NSArray *reverseOrder = [dateArray sortedArrayUsingDescriptors:descriptors];
  </code></pre>
  
  <p>In this way I have an array of NSDate that is correctly ordered. But now, how can I use this order to order my threadList array of custom objects?</p>