Re: Bug in Sort !?!?

*To*: mathgroup at smc.vnet.net*Subject*: [mg126963] Re: Bug in Sort !?!?*From*: David Bailey <dave at removedbailey.co.uk>*Date*: Thu, 21 Jun 2012 05:15:42 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*References*: <jrp94p$qbs$1@smc.vnet.net>

On 19/06/2012 08:18, James Stein wrote: > The documentation says: "Sort orders strings as in a dictionary, with > uppercase versions of letters coming after lowercase ones." It is > therefore unsurprising that { "3", "4", "4b" } are already sorted. > But who can correctly predict the three True/False values produced by > the six lines below? (And who can explain it?) > > s={"3","4","4b"}; > Sort[s] == s > s=Map[StringJoin[#,"."]&,s]; > Sort[s] == s > s=Map[StringJoin[#,"nb"]&,s]; > Sort[s] == s > This boils down to the following puzzling observation: In[20]:= Sort[{".nb", "b.nb"}] Out[20]= {"b.nb", ".nb"} In[19]:= Sort[{"4.nb", "4b.nb"}] Out[19]= {"4b.nb", "4.nb"} As far as I can see, this is inconsistent with the documentation, and I wonder if some kludge was put into the algorithm to do something special with Real numbers embedded in strings! I hope someone from WRI responds! David Bailey http://www.dbaileyconsultancy.co.uk