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 7506125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:09:16+00:00 2026-05-29T22:09:16+00:00

All, I would like to sort this mutable dictionary of arrays keys like so:

  • 0

All,

I would like to sort this mutable dictionary of arrays keys like so: A-Z 0-9 but it’s coming back sorted 0-9 A-Z. How can I sort it such that the alpha chars come before the numbers? Perhaps there is a built-in method that does this or should I create a category that extends NSString?

    NSArray *sKeysArray = [[listContent allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
    NSString *sectionKey = [sKeysArray objectAtIndex:section];
    NSArray *sectionValues = [listContent valueForKey:sectionKey];
  • 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-05-29T22:09:18+00:00Added an answer on May 29, 2026 at 10:09 pm

    Sadly there’s no method in NSString that will directly do this. Instead of writing a category, I would just use NSArrays sortedArrayUsingComparator: method:

    NSArray *sKeysArray = [[listContent ALlKeys] sortedArrayUsingComparator:^(id obj1, id obj2) {
    // Code to compare obj1 and obj2 and return an NSComparisonResult here; return NSOrderedAscending if obj1 should come before obj2 
    }];
    

    To do each comparison, I would use NSString‘s – enumerateSubstringsInRange:options:usingBlock: passing NSStringEnumerationByComposedCharacterSequences for options (basically enumerating characters, except that unicode characters sequences which are actually one “letter” are combined). And when you’re comparing two characters, use something like the answer to this question to detect when obj1 is a number and obj2 is regular letter and return NSOrderedDescending, otherwise just use regular compare:.

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

Sidebar

Related Questions

I have a nested list, List<List<String>> intable; where I would like to sort all
I would like to sort an array of strings (in JavaScript) such that groups
I have a many to many and would like to sort this so that
In Delphi / Pascal I would like to sort a TStringList alphabetically. But for
What i would like to have is sort of this which doesnt work: http://jsfiddle.net/adige72/BS9rp/
I have a find command that I would like to sort such that entries
All I would like to do is create a viewport which maps a 3D
As much as we would all like to say it is a benefit to
I have a DataGridView that I would like all values on a specific row
I have a blog installed in www.foo.com/wp/ and would like all requests that go

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.