Skip navigation.
 
mlRe: Sorting NSStrings in NSTableColumn (need 10 after 9)
FROM : Tom Bradford
DATE : Fri Apr 08 23:11:47 2005

This is a little more difficult than that I think.  You have two values
in there that will cause problems for a standard numeric sort, the first
one is '1/2' which I assume should be converted to a float 0.5 for
sorting.  The second one is 1A whose value is arbitrary.  It could mean
1.0, 1.1, or 1 times A (where the value of A is 50).  In your
comparator, You'd have to account for these cases.

--
Tom Bradford - Virtuoso Technology Evangelist
OpenLink Software: http://www.openlinksw.com/
Personal Web Log:  http://www.tbradford.org/


Ricky Sharp wrote:
>
> 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
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>

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