I’m currently using this compare options to sort a list of strings:
[self compare:aString options:NSNumericSearch|NSCaseInsensitiveSearch];
However, numbers come before than symbols:
99
[Hello
Hello
Is there a way to sort symbols before numbers ?
thanks
Not all symbols come before numbers in the ASCII table, which is why you noticed this behaviour with
'['. Assumingselfin your example is anNSArray, you’ll need to use thesortedArrayUsingComparator:method and implement a custom sorter. (Other classes besidesNSArraywill have this method as well.)Check out Getting Started with Blocks on Apple’s developer site.