Re: Sorting with blank and special characters
Re: Sorting with blank and special characters
- Subject: Re: Sorting with blank and special characters
- From: Deborah Goldsmith <email@hidden>
- Date: Thu, 17 May 2007 10:48:38 -0700
On May 17, 2007, at 4:09 AM, Ricky Sharp wrote:
On Thursday, May 17, 2007, at 05:38AM, "Micha Fuhrmann"
<email@hidden> wrote:
Hi there!
I've got a table view column that's binded to a key of Objects in an
array. That key contains blanks and other special characters such as
"> < " etc. Now, I'd like to sort that column alphabetically then
after "z" have all the special characters and then the blanks.
By default the compare: selector puts the blank and special
characters at the top.
Never, ever use compare: for a sorted list that will be shown to end
users. Always use localizedCompare:.
Well, that's how collation of at least US English works. I believe
that for characters in the ASCII7 space, they'll be listed in order
of their code.
No. Even for ASCII, the order is not code point order. At the very
least, it's aAbBcC, not abc ABC (which would be code point order).
Collation is based on the Unicode Collation Algorithm, which does not
follow code point order:
http://www.unicode.org/reports/tr10/
http://www.icu-project.org/userguide/Collate_Intro.html
http://www.unicode.org/Public/UCA/latest/allkeys.txt
Do you work with Unicode? If so, perhaps they'll be different
sorting according to what data you have along with the user's
collation settings (see International Prefs).
Definitely. This is one reason why it's critical to use
localizedCompare: (or pass the correct locale for
compare:options:locale:).
If all you'll ever deal with is ASCII7, then it would be very easy
to just make your own custom compare method.
Please don't. Even if your software is only sold in the US, there are
non-English speakers in the US. Just as one example, there are a lot
of users of Hawaiian in Hawaii. Hawaiian does not sort in anything
resembling English order. Try setting your sort order to Hawaiian in
International Preferences and enjoy the fun. :-)
There are also Spanish, Chinese, etc. See:
http://en.wikipedia.org/wiki/Languages_in_the_United_States
Deborah Goldsmith
Internationalization, Unicode liaison
Apple Inc.
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