title: Group NSDate in weeks and order from newest to oldest
body: <p>i'm developing an app for iPhone and I'm stuck to this point:</p>
  
  <p>i get this data from an object:</p>
  
  <pre><code>{
      date = "2014-08-04 11:21:26 +0000";
      idChallenger = "-1";
      index = "-1";
      time = "-1";
  },
     {
      date = "2015-07-31 14:50:40 +0000";
      idChallenger = 43;
      index = "-1";
      time = "-1";
  },
      {
      date = "2015-07-31 16:18:57 +0000";
      idChallenger = "-1";
      index = "-1";
      time = "-1";
  },
      {
      date = "2015-07-31 16:19:29 +0000";
      idChallenger = "-1";
      index = "-1";
      time = "-1";
  },
      {
      date = "2015-08-04 15:25:26 +0000";
      idChallenger = "-1";
      index = "-1";
      time = "-1";
  }
  </code></pre>
  
  <p>Now i should get all date, group by weeks and sort from newest to oldest...</p>
  
  <p>At this time I'm stuck to how group NSDate by weeks, the problem starts when there are more years in date, because for example first element in structure is grouped by the last element.</p>
  
  <p>how can I do? Thanks</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>this is the code that I use to group by weeks:</p>
  
  <pre><code>NSMutableArray *weekArray = [NSMutableArray array];
  for (int i = 0; i&lt;52; i++) {
  
      [weekArray addObject:[NSMutableArray array]];
  }
  
  
  for (int i = 0; i&lt;_array.count; i++) {
  
      NSDictionary *dict = [_array objectAtIndex:i];
  
      NSDate *date = [dict objectForKey:@"date"];
  
      NSCalendar *calendar = [NSCalendar currentCalendar];
  
      NSDateComponents *dateComponents = [calendar components:NSCalendarUnitYear | NSCalendarUnitWeekOfYear fromDate:date];
  
      NSMutableArray *innerArray = weekArray[[dateComponents weekOfYear] -1];
      [innerArray addObject:dict];
  }
  
  for (int i = 0; i&lt;weekArray.count; i++) {
  
      if ([[weekArray objectAtIndex:i] count] &gt; 0) {
  
          NSNumber *iNum = [NSNumber numberWithInt:i+1];
  
          [_mutableDictionary setObject:[weekArray objectAtIndex:i] forKey:iNum];
      }
  }
  </code></pre>
  
  <p>_mutableDictionary is:</p>
  
  <pre><code>31 =     (
              {
          date = "2015-07-31 16:19:29 +0000";
          idChallenger = "-1";
          index = "-1";
          time = "-1";
      },
              {
          date = "2015-07-31 16:19:23 +0000";
          idChallenger = "-1";
          index = "-1";
          time = "-1";
      },
              {
          date = "2015-07-31 16:18:57 +0000";
          idChallenger = "-1";
          index = "-1";
          time = "-1";
      },
              {
          date = "2015-07-31 14:50:40 +0000";
          idChallenger = 43;
          index = "-1";
          time = "-1";
      }
  );
  32 =     (
              {
          date = "2015-08-04 15:25:26 +0000";
          idChallenger = "-1";
          index = "-1";
          time = "-1";
      },
              {
          date = "2014-08-04 11:22:40 +0000";
          idChallenger = 43;
          index = "-1";
          time = "-1";
      }
  );
  </code></pre>
  
  <p>31 and 32 are number of week in year</p>
  
  <p>I think that this is wrong for my goal... </p>
  
  <p><strong><em>After group this NSDate in the right way, i must have a structure that allow me to create n section in UITableView for each week</em></strong></p>