title: Sort items in a UITableView by date
body: <p>So in my app, I have a <code>UITableView</code>, and in the navigation controller there is a button to add a new item.  This than takes you to an add an item screen and when you finish, i use a custom delegate to pass the information from the detail viewController to the main <code>tableViewController</code>.  Now that I have the info from delegate, I take the 3 pieces of info and put them in an NSArray in my main Array.  Now my question is, how can I sort the detail items by date.  I have tried (unsuccessfully) 3 times now and I can't seem to figure it out.  The arrays and dictionarys get confusing because they are nested.  Any help is greatly appreciated.</p>
  
  <p>The Delegate Method in the tableViewController class:</p>
  
  <pre><code>-(void)finishedAddingFoodItemFromDetail:(NSDate *)date whatWasEaten:(NSString *)whatFood whichMeal:(NSString *)meal{
  
  NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
  [dateFormatter setDateFormat:@"MMMM d, yyyy"];
  NSString *dateString = [[NSMutableString alloc] init];
  dateString = [dateFormatter stringFromDate:date];
  
  if (!self.theArray) {
      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
      if ([defaults objectForKey:@"theArray"]) {
          self.theArray = [defaults objectForKey:@"theArray"];
      }
      else{
          self.theArray = [[NSMutableArray alloc] init];
      }
  }
  [self.theArray addObject:[NSArray arrayWithObjects:dateString, meal, whatFood, nil]];
  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  [defaults setObject:self.theArray forKey:@"theArray"];
  
  [self.tableView reloadData];
  [self dismissModalViewControllerAnimated:YES];
  }
  </code></pre>
  
  <p>This is the file higharchy I was thinking of, but I can't seem to implement it.</p>
  
  <pre><code>/*  file higharchy
   *   - theBigDict     //large dictionary holding everything
   *       - MutableArray by day stored as objects of theBigDict
   *       - Array of the meals info:
   *           - Meal type
   *           - Food
   */
  </code></pre>