On Jul 28, 2008, at 6:58 PM, Graham Cox wrote:

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?

He didn't say they were the same objects in both arrays, only that the corresponding objects in each array were somehow related.

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

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?


A better understanding of how these arrays are used might help us provide the best solution for you.

For instance, do you always access the 2nd array after finding something in the 1st array? I.e., is it always a one-way street (A- >B), or is it also bi-directional (A<->B). If the former, perhaps instead of 2 arrays, you could keep the one array A sorted, then use a dictionary to keep the value that would otherwise go in array B, keyed off the values in the array, instead of trying to keep 2 arrays in sync.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to