Skip navigation.
 
mlRe: Sorting NSStrings in NSTableColumn (need 10 after 9)
FROM : Ricky Sharp
DATE : Fri Apr 08 23:03:07 2005

On Apr 8, 2005, at 2:50 PM, Lee Morgan wrote:

> Hey all,
> I'm having a problem sorting my NSTableColumn "properly".
> It's filled with NSString objects which currently appear like so..
>
> - 1
> 1
> 1/2
> 10
> 1A
> 2
>
> However I need them to appear like so (the "proper" way)
>
> - 1
> 1/2
> 1
> 1A
> 2
> 10
>
> I'm tried searching the archives, docs, and google but I haven't found
> anything on how to correct this. Sorting the "1/2" case isn't that big
> of a deal, it can pretty much fall where it falls, but the "1A", and
> "2" appearing after "10" is a killer for me.


When comparing your strings, use the NSNumericSearch option

For example, in one of my model's compare: methods, I do this:

- (NSComparisonResult)compare:(IIStudent*)anotherStudent;
{
   return [[self studentName] compare:[anotherStudent studentName]
       options:NSLiteralSearch | NSNumericSearch | NSCaseInsensitiveSearch];
}

___________________________________________________________
Ricky A. Sharp        mailto:<email_removed>
Instant Interactive(tm)  http://www.instantinteractive.com

Related mailsAuthorDate
mlSorting NSStrings in NSTableColumn (need 10 after 9) Lee Morgan Apr 8, 21:50
mlRe: Sorting NSStrings in NSTableColumn (need 10 after 9) Ricky Sharp Apr 8, 23:03
mlRe: Sorting NSStrings in NSTableColumn (need 10 after 9) Tom Bradford Apr 8, 23:11
mlRe: Sorting NSStrings in NSTableColumn (need 10 after 9) Lee Morgan Apr 8, 23:50
mlRe: Sorting NSStrings in NSTableColumn (need 10 after 9) Lee Morgan Apr 9, 03:21