I don't find these results consistent:
OrderedQ[{"a", "A"}]
True
OrderedQ[{"a2", "A1"}]
False
Is there any explanation of that somewhere? (In fact it is not necessarily related to Mathematica, maybe there are some standards or established conventions about this.)
One could think that the explanation is: since "a" and "A" are equivalent
and as OrderedQ[{"A", "A"}]
returns True
, it's normal. But in that case OrderedQ[{"A", "a"}]
shouldn't return False
.
EDIT
(Thanks to @Michael E2 comments)
It turns out that this question has nothing to do with the fact that "1" and "2" are digit characters. The same thing happens if one replaces "1" by "c" and "2" by "d" for example.
EDIT2
This has been tested on Mathematica 11.3 and 5.1
string[1] > string2[1]
implies thatstring1 > string2
. This is clearly not the case here. Mathematica uses some more complex and more confusing ordering. $\endgroup$OrderedQ[{{"a", "2"}, {"A", "1"}}]
-->True
. If upper/lowecase is treated specially, does that mean that: (1) ordering is language dependent (consider Turkish dotted uppercaseİ
and dotless lowercaseı
)? If yes, what language does M use? (2) ordering is not well-defined for certain scripts? $\endgroup$Sort[{"I2", "İ2", "i2", "ı2", "I1", "İ1", "i1", "ı1"}]
-->{"İ1", "İ2", "i1", "ı1", "I1", "i2", "ı2", "I2"}
. My point is that the note in the documentation does not give an unambiguous description of what is going on. $\endgroup$