Re: Why Sort[{"AX", "!D", "EX"}] -> {"AX", "!D", "EX"} ?
- To: mathgroup at smc.vnet.net
- Subject: [mg76150] Re: Why Sort[{"AX", "!D", "EX"}] -> {"AX", "!D", "EX"} ?
- From: Philipp <Philipp.M.O at gmail.com>
- Date: Thu, 17 May 2007 05:48:24 -0400 (EDT)
- References: <f26nv5$4cl$1@smc.vnet.net><f2951r$mu8$1@smc.vnet.net>
Jens, Actually you can set "your" own order. If you're happy, say, with ASCII 0-127 order, the comparison function for 2 letter strings could be: In[]:= Sort[{"AX", "!D", "EX"}, (ToCharacterCode[#1]+1).{128, 1} < (ToCharacterCode[#2]+1).{128, 1} &] Out[]= {"!D", "AX", "EX"} This workaround is pretty slow, and, of course, it does not explain the weirdness of Mathematica 5.2 canonical order as demonstrated in my original post. Cheers, Philipp. On May 14, 4:02 pm, Jens-Peer Kuska <k... at informatik.uni-leipzig.de> wrote: > Hi, > > and set the comparison test as *you* interpret/understand > the order does not help > > Regards > Jens > > > > Philipp wrote: > > Would anybody explain to me the Mathematica (5.2) canonical order. > > Specifically, why > > > In[]:= Sort[{"AX", "!D", "EX"}] > > Out[]= {"AX", "!D", "EX"} > > > while, > > > In[]:= Sort[{"A", "!", "E"}] > > Out[]= {"!", "A", "E"} > > > Is this a bug??? > > > Cheers, > > > Philipp.- Hide quoted text - > > - Show quoted text -