• 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
Re: sorting two arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sorting two arrays


  • Subject: Re: sorting two arrays
  • From: Graham Cox <email@hidden>
  • Date: Tue, 29 Jul 2008 10:58:05 +1000

Jeff,

This has a bit of a whiff about it. Two arrays of the same objects is not unusual, but forcing them always into the same order is - surely that's just a data duplication? If the arrays are meant to be identical, why not just use one array? What is different?

If array B contains array A + some extra objects (which after sorting will always be pushed to the end of the array), maybe a better pattern would be to keep just these additional objects in array B and just tack them on to the end of array A when a complete list is requested. Then your problem reduces to "how do I sort an array?" which Cocoa gives you. A bit more of an overview of what you're actually trying to do would help.

cheers, Graham



On 29 Jul 2008, at 1:08 am, Jeff LaMarche wrote:

Hey all...

I've got two arrays that are related, so that object 0 in one array corresponds to object 0 in the other array. I'd like to implement a sort based on the values in one array, but to reorder both array so that the order of the two arrays stays in sync and that object x in one array continues to correspond to the same thing as object x in the other array after the sort.

I've got a general idea of how to implement the sort, but since I know that there are a few places in the system where array pairs are used like this, I wanted to see if there was any out-of-the-box way of handling this scenario - I'd hate to reinvent the wheel if it's not necessary. Does anyone know if there is any easy way to do this?

TIA,
Jeff

_______________________________________________

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

_______________________________________________

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: sorting two arrays
      • From: Randall Meadows <email@hidden>
References: 
 >sorting two arrays (From: Jeff LaMarche <email@hidden>)

  • Prev by Date: Re: Setting conditional breakpoint on Cocoa method? [SOLVED]
  • Next by Date: Re: sorting two arrays
  • Previous by thread: Re: sorting two arrays
  • Next by thread: Re: sorting two arrays
  • Index(es):
    • Date
    • Thread