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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:32:30+00:00 2026-05-28T01:32:30+00:00

I have an array, with some names (String) in it. 1.) I want to

  • 0

I have an array, with some names (String) in it.

1.) I want to list these names in the array in alphabetical order.
2.) Later i will add some more names to this array, so it had to get appended to this array.

How can i do this programatically ?

note: i don’t have any code to demonstrate my working so far. i just have an array created.

EDIT

If my array declaration is ;

NSArray *array = [NSArray arrayWithObjects:@"A",@"C",@"B", @"M",nil];

how can i sort this ?

  • 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-28T01:32:31+00:00Added an answer on May 28, 2026 at 1:32 am

    You should really try getting used to looking at documentation – once you get the hang of it you can figure things out pretty quickly

    The docs for NSArray give you the exact way to sort an array:

    NSArray *array       = [NSArray arrayWithObjects:@"A", @"C", @"B", @"M", nil];
    NSArray *sortedArray = [array sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
    

    Now considering you are wanting to add objects later you will most likely use an NSMutableArray the docs for NSMutableArray show the method:

    - (void)sortUsingSelector:(SEL)comparator
    

    Therefore you could use

    NSMutableArray *myMutableArray = [NSMutableArray arrayWithObjects:@"c", @"a", @"b", nil];
    [myMutableArray sortUsingSelector:@selector(caseInsensitiveCompare:)];
    

    which will sort your array in place resulting in

    2012-01-10 17:47:11.477 Untitled[11904:707] (
        a,
        b,
        c
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a List or Array of some sort, storing this information
I have an array with some value like this: [Organization_id] => Array ( [0]
I have an array named 'names' with strings looking like this: [name_23_something, name_25_something, name_2_something];
i have an array of names which have multiple files and folders...now i want
friends. I have an array and it contains some string values. ex: array name=All_array
I want to pass some image names and numbers as string to my flash,
I have a List of objects which contain a string array as one of
I have an array set inside a velocity template that contains some paths. The
I have a class 'Data' that uses a getter to access some array. If
If I have an array of say, some ID's of users. How could i

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.