title: Sorting UITableView
body: <p>I want to do a basic sorting of a <code>UITableView</code> that is generated from <code>MPMediaQuery</code>.</p>
  
  <p>What I want is to just have a basic songs list that sorts the songs into sections of A, B, C, D, etc. Shouldn't be hard, but every tutorial I've tried to follow ends up no giving me those results at all. </p>
  
  <p>Any help would be wonderful. Here is my basic code. I realize this is not even close to having what I want accomplished, but I figured it would be easier for a seasoned developer to help me from this point then the mess I was in.</p>
  
  <p>How I generate my data:</p>
  
  <pre><code>MPMediaQuery *musicLibraryQuery = [[MPMediaQuery alloc] init];
  NSArray *musicLibraryArray = [musicLibraryQuery items];
  songLibrary = [NSMutableArray arrayWithArray:musicLibraryArray];
  </code></pre>
  
  <p>These are my UITableView methods:</p>
  
  <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      return [songLibrary count];
  }
  
  - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"SongCell";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
      if(!cell)
      {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      }
  
      MPMediaItem *song = [[songLibrary objectAtIndex:[indexPath row]] representativeItem];
  
      cell.textLabel.text = [song valueForProperty:MPMediaItemPropertyTitle];
  
      return cell;
  }
  </code></pre>