Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10543 > unrolled thread
| Started by | James Stein <mathgroup@stein.org> |
|---|---|
| First post | 2012-06-19 07:18 +0000 |
| Last post | 2012-06-22 07:01 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | James Stein <mathgroup@stein.org> |
|---|---|
| Date | 2012-06-19 07:18 +0000 |
| Subject | Bug in Sort !?!? |
| Message-ID | <jrp94p$qbs$1@smc.vnet.net> |
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
[toc] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2012-06-21 09:16 +0000 |
| Message-ID | <jruopo$fhp$1@smc.vnet.net> |
| In reply to | #10543 |
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
[toc] | [prev] | [next] | [standalone]
| From | nanobio9 <kuokan.liang@gmail.com> |
|---|---|
| Date | 2012-06-21 09:16 +0000 |
| Message-ID | <jruoop$fhg$1@smc.vnet.net> |
| In reply to | #10543 |
On 6=E6=9C=8819=E6=97=A5, =E4=B8=8B=E5=8D=883=E6=99=8218=E5=88=86, James Stein <mathgr...@stein.org> 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
The character code of "." is 46, smaller than "a", "1", etc. I do not
see a bug here.
Regards,
KKL
[toc] | [prev] | [next] | [standalone]
| From | James Stein <mathgroup@stein.org> |
|---|---|
| Date | 2012-06-22 07:01 +0000 |
| Message-ID | <js158b$ke4$1@smc.vnet.net> |
| In reply to | #10543 |
KKL is correct; my apologies to all.
On Thu, Jun 21, 2012 at 2:15 AM, nanobio9 <kuokan.liang@gmail.com> wrote:
> On 6=E6=9C=8819=E6=97=A5, =E4=B8=8B=E5=8D=883=E6=99=8218=E5=88=86, James Stein <mathgr...@stein.org> 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
>
> The character code of "." is 46, smaller than "a", "1", etc. I do not
> see a bug here.
>
> Regards,
> KKL
>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web