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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:22:00+00:00 2026-06-13T18:22:00+00:00

I have an array which contains some strings. For each character of a string

  • 0

I have an array which contains some strings. For each character of a string an integer value is assigned. For example a=2,b=5,c=6 ,o=1,k=3 etc

The final value in the a string is the sum of the character’s value. So that for an example string “BOOK” the string will be stored as “BOOK (7)”. Similarly every string will have a final integer value. I would like to sort these array with these final integer values stored in the string which is present in each array index. The array contains more than 200,000 words. So the sorting process should be pretty fast. Is there any method for it?

  • 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-13T18:22:02+00:00Added an answer on June 13, 2026 at 6:22 pm

    A brutal quick example could be, if your strings structure is always the same, like “Book (7)” you can operate on the string by finding the number between the “()” and then you can use a dictionary to store temporally the objects:

        NSMutableArray *arr=[NSMutableArray arrayWithObjects:@"Book (99)",@"Pencil (66)",@"Trash (04)", nil];
        NSLog(@"%@",arr);
    
        NSMutableDictionary *dict=[NSMutableDictionary dictionary];
        //Find the numbers and store each element in the dictionary 
        for (int i =0;i<arr.count;i++) {
            NSString *s=[arr objectAtIndex:i];
            int start=[s rangeOfString:@"("].location;
            NSString *sub1=[s substringFromIndex:start];
            NSString *temp1=[sub1 stringByReplacingOccurrencesOfString:@"(" withString:@""];
            NSString *newIndex=[temp1 stringByReplacingOccurrencesOfString:@")" withString:@""];
            //NSLog(@"%d",[newIndex intValue]);
            [dict setValue:s forKey:newIndex];
        }
        //Sorting the keys and create the new array
        NSArray *sortedValues = [[dict allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
        NSMutableArray *newArray=[[NSMutableArray alloc]init];
        for(NSString *valor in sortedValues){
                   [newArray addObject:[dict valueForKey:valor]];
            }
        NSLog(@"%@",newArray);
    

    This prints:

    (
    “Book (99)”,
    “Pencil (66)”,
    “Trash (04)”
    )

    (
    “Trash (04)”,
    “Pencil (66)”,
    “Book (99)”
    )

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

Sidebar

Related Questions

I have an array ($configOptions) which contains some arrays. Each array ($option) in that
I have this 2D array (say double[10][10]) which contain some 1.0 and 10.0, rest
I have an controller which is an ArrayProxy and contains some computed arrays. In
I have an array which contains 12 numbers and I want to save this
I have an array which contains a set of UIImage in byte forms. --My
I have an array which contains another array Would I notate it this way?
I have an array which contains around 50-200 hyperlinks. How can I pass this
I have an array which contains sets of three similar named items; however, sometimes
Am I missing something in the Array documentation? I have an array which contains
I have a cell array which contains 7 matrices of varying column and length

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.