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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:18:50+00:00 2026-06-14T21:18:50+00:00

I am sorting an NSMutableArray on my field date but it does not take

  • 0

I am sorting an NSMutableArray on my field “date” but it does not take into account the time. If the date is the same, the time is still sorted random. What am I doing wrong? The field “date” is of the type NSDate.

 NSSortDescriptor *dateDescriptor =
[[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
NSArray *descriptors = [NSArray arrayWithObjects:dateDescriptor, nil];

[self.player1ScoreT sortedArrayUsingDescriptors:descriptors];

My output is:
2012-11-25 11:01:00 +0000
2012-11-25 11:00:56 +0000
2012-11-25 11:00:54 +0000
2012-11-25 11:01:03 +0000

Strange…..

  • 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-14T21:18:51+00:00Added an answer on June 14, 2026 at 9:18 pm

    The logic you’re using to sort is correct, I’ve just tried it and it works fine.

    I assume it’s because of [self.player1ScoreT sortedArrayUsingDescriptors:descriptors];, this will not change the array held in self.player1ScoreT, rather, it produces a new array. This is because you’re using a selector that will not mutate the original array (NSArray itself is not mutable by design, NSMutableArray is mutable).

    As such, you’ll want to use this:

    self.player1ScoreT = [self.player1ScoreT sortedArrayUsingDescriptors:descriptors];
    

    This will reassign the array within self.player1ScoreT to be the new sorted array, produced by sortedArrayUsingDescriptors:, and the old unsorted one will be discarded.

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

Sidebar

Related Questions

there have already been lots of questions asked for Sorting of an NSMutableArray still
I've looked around and seen several postings concerning sorting NSMutableArray's that contain NSDictionaries, but
I'm doing some small work on sorting the date strings in the NSMutableArray, i'm
Result-Sorting Fulltext on AppEngine Java on a Date Field. How to? using SDK 1.6.6
I'm sorting a NSMutableArray that has NSString that contain numbers. This is the code
Possible Duplicate: How to sort an NSMutableArray with custom objects in it? How does
Maybe someone can enlighten me on this subject. I'm sorting a NSMutableArray declared as
Possible Duplicate: sorting in nsmutable array I have 2 NSMutableArray array. I have to
I got problem for sorting array of nsdate. so i have array of date
Can someone please show me the code for sorting an NSMutableArray? I have the

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.