Re: Numeric comparison in string
Re: Numeric comparison in string
- Subject: Re: Numeric comparison in string
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 30 Mar 2002 17:20:37 -0800
On 3/30/02 5:10 PM, "JJ" <email@hidden> wrote:
>
Why this returns "true" and not "can't make some data into the expected
>
type" or anything similar?
>
>
"1.2.1" < "1.5.3"
>
>
Obviously, these strings can't be coerced to real. Are they internally
>
co-re-coerced to hexadecimal, suppossing they're "version" numbers?
>
It's not a numeric comparison, it's a string comparison, in the same way
that
"a" < "d"
is true, and
"abcde" < "adcde"
just like the phone book. That's why you can get those silly lists, sorted
as string, which look like:
1 Some String
10 Some String
103 Main Street
2 Some String
3 Some String
33546 Some String
37 Any Old String
4 Nonsense String
etc. The Finder used to sort by list this way. I believe that the string
ordering of numeric-characters-as-string is determined by their ASCII
numbers, as for all string characters. So some punctuation characters come
first, the 0-9, then some more punctuation and symbols, then A-Z and a few
more, then a-z, then all the wild "upper-ASCII"s.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.