Re: Re: Why Sort[{"AX", "!D", "EX"}] -> {"AX", "!D", "EX"}
- To: mathgroup at smc.vnet.net
- Subject: [mg76051] Re: [mg75994] Re: Why Sort[{"AX", "!D", "EX"}] -> {"AX", "!D", "EX"}
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Tue, 15 May 2007 04:59:45 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <f26nv5$4cl$1@smc.vnet.net> <200705140753.DAA23316@smc.vnet.net>
- Reply-to: murray at math.umass.edu
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.
>>
>>
>
> http://documents.wolfram.com/mathematica/book/section-A.3.9
>
> 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 math.umass.edu
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
- References:
- Re: Why Sort[{"AX", "!D", "EX"}] -> {"AX", "!D", "EX"} ?
- From: Szabolcs <szhorvat@gmail.com>
- Re: Why Sort[{"AX", "!D", "EX"}] -> {"AX", "!D", "EX"} ?