Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10560
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Bug in Sort !?!? |
| Date | 2012-06-21 09:16 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jruopo$fhp$1@smc.vnet.net> (permalink) |
| 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
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bug in Sort !?!? James Stein <mathgroup@stein.org> - 2012-06-19 07:18 +0000 Re: Bug in Sort !?!? David Bailey <dave@removedbailey.co.uk> - 2012-06-21 09:16 +0000 Re: Bug in Sort !?!? nanobio9 <kuokan.liang@gmail.com> - 2012-06-21 09:16 +0000 Re: Bug in Sort !?!? James Stein <mathgroup@stein.org> - 2012-06-22 07:01 +0000
csiph-web