• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
sort array of dictionaries by multiple critera
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sort array of dictionaries by multiple critera


  • Subject: sort array of dictionaries by multiple critera
  • From: Martin Batholdy <email@hidden>
  • Date: Wed, 27 Apr 2011 15:59:05 +0200

Hi,

I have an array of dictionaries.

One dictionary-entry looks like this:

{
    ID = 34;
    counter = 2;
    date = "2011-04-19 15:43:52 +0200";
    title = "test.pdf";
    type = file;
}

Now I would like to sort my array of dictionaries first by type and then (within the type-dictionaries) by date.

I can sort my array by one critierion with a NSSortDescriptor:

NSSortDescriptor *descriptor;
descriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
[bookmarks sortUsingDescriptors:[NSArray arrayWithObjects:descriptor, nil]];


but how can I first "group" the dictionaries by type and then within the types sort them by date?
(so use two sorting-criteria with a different priority)



thanks for any suggestions!_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: sort array of dictionaries by multiple critera
      • From: Graham Cox <email@hidden>
    • Re: sort array of dictionaries by multiple critera
      • From: Steve Christensen <email@hidden>
    • Re: sort array of dictionaries by multiple critera
      • From: Dave DeLong <email@hidden>
  • Prev by Date: Re: Stack of NSWindow sheets
  • Next by Date: Re: sort array of dictionaries by multiple critera
  • Previous by thread: Re: Stack of NSWindow sheets
  • Next by thread: Re: sort array of dictionaries by multiple critera
  • Index(es):
    • Date
    • Thread