MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Why Sort[{"AX", "!D", "EX"}] -> {"AX", "!D", "EX"}

  • To: mathgroup at
  • Subject: [mg76051] Re: [mg75994] Re: Why Sort[{"AX", "!D", "EX"}] -> {"AX", "!D", "EX"}
  • From: Murray Eisenberg <murray at>
  • Date: Tue, 15 May 2007 04:59:45 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <f26nv5$4cl$> <>
  • Reply-to: murray at

The docs cited DO seem to say how strings are ordered: "as they would be 
in a dictionary....".

Is "!" a "mathematical operator" or is it just a character in the 
examples at issue?

With dictionary ordering, the primary key for sorting would be the first 
character.  So none of this explains the discrepant behavior between "!" 
as a single character and "!" as the first character of a string.

Szabolcs wrote:
> 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.
> Most probably it has to do something with the "Mathematical operators 
> appear in order of decreasing precedence." part.
> This behaviour is too consistent to be a bug (i.e. unintended 
> behaviour), but it is really confusing. The documentation only mentions 
> the ordering of single characters, but not how longer strings are 
> treated, and it seems that it doesn't work as most people would expect 
> it to.

Murray Eisenberg                     murray at
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

  • Prev by Date: Re: Where is the Mathematica Book in Documentation Center?
  • Next by Date: Re: error message Convert::incomp in units package of Mathematica 6.0
  • Previous by thread: Re: Why Sort[{"AX", "!D", "EX"}] -> {"AX", "!D", "EX"} ?
  • Next by thread: Re: -> {"AX", "!D", "EX"}