Re: Sorting NSStrings in NSTableColumn (need 10 after 9)
Re: Sorting NSStrings in NSTableColumn (need 10 after 9)
- Subject: Re: Sorting NSStrings in NSTableColumn (need 10 after 9)
- From: Tom Bradford <email@hidden>
- Date: Fri, 08 Apr 2005 17:11:47 -0400
- Organization: OpenLink Software
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@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden