• 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 Array Alphabetically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting Array Alphabetically


  • Subject: Re: Sorting Array Alphabetically
  • From: Deborah Goldsmith <email@hidden>
  • Date: Fri, 13 Apr 2007 13:17:58 -0700

I think the first one will work the way you want by passing NSString's compare:

Not quite. Based on the sample data, I'm guessing this sort is intended to be shown to an end user. compare: should *never* be used to sort a list for display to an end user. It does a comparison based on the Unicode code point values, which is not what most users would consider "sorted."


Lists being sorted for end users should *always* use localizedCompare: or localizedCaseInsensitiveCompare:. Only use compare: if the end user will not see the ordering.

Deborah Goldsmith
Internationalization, Unicode liaison
Apple Inc.
email@hidden

On Apr 13, 2007, at 6:57 AM, Shamyl Zakariya wrote:

Look at NSMutableArray
- (void) sortUsingSelector:
- (void) sortUsingFunction:(int (*)(id, id, void *))compare context:(void *)context
- (void) sortUsingDescriptors:(NSArray *)sortDescriptors


I think the first one will work the way you want by passing NSString's compare:

Shamyl Zakariya
	"there is no emoticon, for what I am feeling"



On Apr 13, 2007, at 8:53 AM, Micha Fuhrmann wrote:

Hi there!


I've looked around and couldn't find anything.

I've got a NSMutableArray with Strings in it. Po the Array in gdb gives the list of it with the strings and not objects such as:

<NSCFArray 0x3a3e80>(
Nightmares On Wax,
John Martyn,
The Kinks,....

Now, I'd like to sort this Array Alphabetically, how do I go about?

Any help would be appreciated. Also, if I've missed something, like NSMutableArray shouldn't be filled with plain strings but objects in manner to give me more control please let me know.

Micha
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
40zakariya.net


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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)

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 Array Alphabetically
      • From: Jeff C <email@hidden>
    • Re: Sorting Array Alphabetically
      • From: Ricky Sharp <email@hidden>
    • Re: Sorting Array Alphabetically
      • From: Shamyl Zakariya <email@hidden>
    • Re: Sorting Array Alphabetically
      • From: Robert Walker <email@hidden>
References: 
 >Sorting Array Alphabetically (From: Micha Fuhrmann <email@hidden>)
 >Re: Sorting Array Alphabetically (From: Shamyl Zakariya <email@hidden>)

  • Prev by Date: Re: Possible to draw an NSMutableAttributedString into a CGContextRef?
  • Next by Date: Re: Sorting Array Alphabetically
  • Previous by thread: Re: Sorting Array Alphabetically
  • Next by thread: Re: Sorting Array Alphabetically
  • Index(es):
    • Date
    • Thread