On Jun 28, 2011, at 5:52 AM, Rick C. wrote:

> I have a pair of arrays (one of integers and one of strings) and I need to 
> sort the one of integers from largest to smallest and then however it gets 
> sorted I need to copy that sorting in my strings array since they are 
> related.  Any advice on what the best way to approach this is would be great 
> since I don't have a lot of experience in sorting like this.  Thanks!

Another way to do this, besides what’s been suggested, is to make a new numeric 
array that maps old indexes to sorted indexes. Start it out as the identity 
(a[i] = i), then sort it using a compare function that compares the ints mapped 
into your original int array. Then use the sorted index mapping to renumber 
your original arrays.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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 arch...@mail-archive.com

Reply via email to