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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:50:00+00:00 2026-05-30T03:50:00+00:00

I have NSMutableArray days which contain 7 NSMutableArrays,7 NSMutableArrays contain class Lesson. @interface Lesson

  • 0

I have NSMutableArray “days” which contain 7 NSMutableArrays,7 NSMutableArrays contain class Lesson.

@interface Lesson : NSObject <NSCoding>{
    NSString *time1;
    NSString *time2;
    NSString *predmet;
    NSString *namPrepod;
    NSString *zamet;
} 

Before I was doing sort with sortedArrayUsingComparator, but now I must do sort with sortedArrayUsingDescriptors;

sortedArrayUsingComparator look like

chetNedel.sunday = [NSMutableArray arrayWithArray:[chetNedel.sunday sortedArrayUsingComparator:^(id cont1, id cont2) { return [[(Lesson *) cont1 time1] compare:[(Lesson *) cont2 time1]]; }]];
[chetNedel.days removeObjectAtIndex:0];
[chetNedel.days insertObject:chetNedel.sunday atIndex:0];

how will be sorted with sortedArrayUsingDescriptors?

  • 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-30T03:50:02+00:00Added an answer on May 30, 2026 at 3:50 am

    This is the method you’ll use on the NSMutableArray you want to sort.

    - (void)sortUsingDescriptors:(NSArray *)sortDescriptors
    

    So you want to sort an array of Lesson objects. The NSArray parameter is going to be an array of NSSortDescriptor objects.

    An NSSortDescriptor describes how you’re going to sort an object based off it’s properties. So in your case of sorting Lesson objects, you’re going to sort on some or all of the string properties you have.

    This is a sort descriptor for your Lesson object, we’ll be sorting them on their time1 property.

    NSSortDescriptor *time1Descriptor = [[NSSortDescriptor alloc] initWithKey:@"time1" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
    

    The key parameter is your objects property you want to compare (or you could use time2, premedt, ect). The ascending property is a boolean on whether you want the sorted values to be returned in an increasing or decreasing order. The selector property is a method that will be used to compare the properties of your object.

    Now back to the NSArray of sort descriptors. At this point you’d start constructing your array of sort descriptors.

    NSArray *sortDescriptorArray = [[NSArray alloc] initWithObjects:time1Descriptor, nil];
    

    And pass this array of sort descriptors to the original method: - (void)sortUsingDescriptors:(NSArray *)sortDescriptors

    [myArrayOfLessions sortUsingDescriptors:sortDescriptorArray];
    

    Your original array of lessons is now sorted.

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

Sidebar

Related Questions

I have some NSMutableArray in tableView which contain class Lesson @interface Lesson : NSObject
I have NSMutableArray day which contain (6 NSMutable arrays) arrays contain class Lesson{ NSString
I have in tableView NSMutableArray days which contain 6 NSMutableArray (monday, tuesday...saturday) Before I
I have a class that subclasses NSMutableArray. I init it using: MyClass class =
I have an NSMutableArray of custom objects. The custom object (Tag Class) has an
I have a NSMutableArray which i am initializing from a plist with strings. but
I have an NSMutableArray called myObjectArray which contains and array of NSObjects called myObject.
I have a NSMutableArray with the following objects: @interface MyViewCell : UITableViewCell { NSUInteger
I have a NSMutableArray which repeatedly will be filled with the changing contents of
I have an NSMutableArray in my class containing Ingredient objects. I want to check

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.