• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Numeric comparison in string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Numeric comparison in string (From: JJ <email@hidden>)

  • Prev by Date: Shell script date & time coercions...
  • Next by Date: Language guide edition for AS 1.3.7, published in 1999...
  • Previous by thread: Numeric comparison in string
  • Next by thread: Language guide edition for AS 1.3.7, published in 1999...
  • Index(es):
    • Date
    • Thread