sort data and display in UItableview on iphone
<p>i am using this query to get the data by ASC order
<strong>select * from list_tbl where cat_id=%d order by names ASC</strong></p>

<p>now my table view shows data based on ASC order 
then i used this to get the letters from A to Z on right side</p>

<pre><code>- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)help
{
    return [[[UILocalizedIndexedCollation currentCollation] sectionTitles] objectAtIndex:help];
}
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
    return [[UILocalizedIndexedCollation currentCollation] sectionIndexTitles];
}



- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
    return [[UILocalizedIndexedCollation currentCollation] sectionForSectionIndexTitleAtIndex:index];
} 
</code></pre>

<p>now my problem is how to <strong>divide data based on section header</strong> like all A content goes to A and then B  till Z and when user click on any alphabet on right side it should goes to that section</p>

<p><strong>// UPDATES ///////////////</strong></p>

<pre><code>-(void)setUpRecordsForIndexing
{

        for (NSString * recordName in appDelegate.catLists)//where app.catList contains all the value
        {
           NSString *firstLetter = ([recordName length] ==0)?miscKey:[[recordName substringToIndex:1]uppercaseString];
            /*if(![firstLetter beginsWithCharacterInSet:[NSCharacterSet letterCharacterSet]] || [recordName isEqualToString:@""] || recordName == nil )
                firstLetter = miscKey ;
        */  
            NSMutableArray *indexArray = [IndexedRecords objectForKey:firstLetter];
            if (indexArray == nil) 
            {
                indexArray = [[NSMutableArray alloc] init];
                [IndexedRecords setObject:indexArray forKey:firstLetter];
                [IndexLetters addObject:firstLetter];
                [indexArray release];
            }
            [indexArray addObject:record];// this is not workking

        //  NSLog(@" index array is %@",indexArray);
        }
    }
</code></pre>

<p><strong>my  INDEXRECORD is not showing correct value
i can now divide the section based on ABCD but each sections are having same content , what i am doing wrong</strong> </p>
