Re: kCFCompareNumerically
Re: kCFCompareNumerically
- Subject: Re: kCFCompareNumerically
- From: Ondra Cada <email@hidden>
- Date: Mon, 14 Jan 2002 12:31:58 +0100
Steve,
>
>>>>> Steve Gehrman (SG) wrote at Sun, 13 Jan 2002 22:11:30 -0800:
SG> "kCFCompareNumerically is currently ignored in the Compare routines."
I don't have a slightest idea how this should work, but...
SG> Does anyone have code that will compare NSStrings numerically ie:
SG> Foo2.txt < Foo7.txt < Foo25.txt
...regarding this example, I guess you are after something like
NSComparisonResult numericStringCompare(NSString *a,NSString *b) {
int plen=[[a commonPrefixWithString:b options:0] length];
return [[a substringFromIndex:plen] intValue]-[[b substringFromIndex:plen]
intValue];
}
Not tested, might contain some bugs, but is simple enough to be fixed.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc