sorting decomposed strings with options

Hello,
MacOSlib has got a Unicode Extension Example, where the label at the top says that with the right options it is possible to sort strings as the Finder does.
The example shows how to do strCompare and Find with options, but I’m not expert enough to guess how to proceed for sorting.
So, I decompose a string: s.NormalizeUnicodeToNFD, but then how to apply the options to .sort?
Thanks.

What do you want to do? The easiest way would be to totally normalize your data. If you don’t want to do this then put the normalized data into a second array and use SortWith.

I put the s.NormalizeUnicodeToNFD into an invisible column of a listbox, and sort the original column by the invisible column.
Yet, characters like ? and the like don’t get sorted in the right way; for instance, ? takes its place before A.
I tried also convertencoding (encodings.ASCII), but with the same partial results.
Anyway, how to “totally normalize data”?
Thanks.

With “totally normalize data” I mean replacing the unnormalized data with normalized data.

But your example doesn’t have anything to do with normalization. This is something different. Normalization is having characters as “e´” versus one character like “é”. You want to have unicode sorting. The docs don’t say anything about the sort method of the listbox.

I’m using the old SortLibrary from Charles Yeomans for this. There I then plug in the sort I need. For instance:

[code] const NSCaseInsensitiveSearch = 1
const NSDiacriticInsensitiveSearch = 128

Return NSStringCompareMBS(s1, s2, NSDiacriticInsensitiveSearch + NSCaseInsensitiveSearch)[/code]

or

[code] const NSCaseInsensitiveSearch = 1

Return NSStringCompareMBS(s1, s2, NSCaseInsensitiveSearch)[/code]

Beatrix,
could you please send me Charles’ SortLibrary in order to sort string-arrays (i.e. arrays not linked to any listbox)?

As for a listbox, relying on your tip, I get the right sorting with this code in the compareRow handler:

select case column
case 0
'const NSCaseInsensitiveSearch = 1//constants already present in macOSlib
'const NSNumericSearch = 64
'//const NSForcedOrderingSearch = 512
'const NSDiacriticInsensitiveSearch = 128

result = StrCompWithOptions(me.cell(row1,column), me.cell(row2,column), NSCaseInsensitiveSearch + const NSNumericSearch + NSDiacriticInsensitiveSearch)
Return true  

end Select

Thank you.