Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8151807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:30:39+00:00 2026-06-06T15:30:39+00:00

I am sorting and sectioning a tableview using the first letter of an array

  • 0

I am sorting and sectioning a tableview using the first letter of an array of strings, just like the Contacts app does. I’m using Core Data and NSFetchedResultsController to drive the tableview. I use the first letter of the word, and if the letter isn’t Only issue is, when I use a sort description with localizedCaseInsensitiveCompare:, it seems to generate the list of sections with: ‘#’, ‘A’, ‘B’ … ‘Z’. I want the # to come at the end of the list, not the first (just like the Contacts app, again). Is there any creative way I could accomplish this?

Here’s how I’m creating the NSFetchedResultsController:

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

NSEntityDescription *entity = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
[fetchRequest setFetchBatchSize:100];

NSSortDescriptor *sortDescriptorLetter = [[NSSortDescriptor alloc] initWithKey:@"sectionLetter" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptorLetter, nil];
[fetchRequest setSortDescriptors:sortDescriptors];

NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"sectionLetter" cacheName: nil]; // NOTE: set the cache name to nil for testing ...

aFetchedResultsController.delegate = self;
self.fetchedResultsController = aFetchedResultsController;

 NSError *error = nil;
 if (![self.fetchedResultsController performFetch:&error])
 ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:30:42+00:00Added an answer on June 6, 2026 at 3:30 pm

    Apparently you can’t customize sort descriptors when using the NSFetchedResultsController. You have to go with the standard sorting selectors, like “localizedCaseInsensitiveCompare”.

    The way I ended up doing this is to take the NSFetchedResultsController results and tweaking the boilerplate code for setting up the tableView with my own mapping of indexPaths, where I off-set the 0th section to the last section of the table. It’s a bit of work, and it might just be better to forget using NSFetchedResultsController and load all the objects directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When sorting a table of objects from Core Data, I'd like to set a
iam using leigeber's sorting javascript to sort my data on my page......i took the
Sorting five integers using bitwise or comparison operators can be achieved by first getting
A class project involves sorting an array of strings, with each string containing an
I need help sorting [Time] data from in this array in php. For a
I tried sorting strings using bubblesort, but I dont know whether it makes any
I've a problem sorting an nsarray. The nsarray is filled with core data: NSFetchRequest
I got problem for sorting array of nsdate. so i have array of date
I need help sorting through some data. Say I type piz in a searchfield.
The autofilter is sorting data vertically, but I want to filter rows horizontally. Lets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.