WRT replicating it: I also tried prior to the post and cannot, I was hoping there might be an obtuse reason someone is aware of, since I am positive about the data, etc. Ie, this is not a coding error. Here's exactly the way I am verifying the issue right now:

if ($#Terms > 0) { print "HERE\n"; # to confirm this takes place; @Notes = sort { $b->{terms} <=> $a->{terms} } @Notes; } my @Sorted = sort { $b->{terms} <=> $a->{terms} } @Notes; print "$#Notes $#Sorted\n"; for (my $i = 0; $i<=$#Notes; $i++) { print $Notes[$i]->{terms}.$Sorted[$i]->{terms}."\n"; }

The output begins:

HERE 1008 1008 12 12 12 12 12 [..etc: nb, there is never anything other than 1 or 2]

As if "@Notes" were scoped locally in the if block. Again, this not normal behaviour nor can I replicate it in a simpler script. However, I do not see possibility of bad data affecting the above logic (please tell me specifically how you think it could, if you do). These are two versions of the same sort operation on the same array.

Interestingly, if I make a single change, by moving "my @Sorted = sort" to before the if block instead of after it (making it the first line in the above code) both arrays are the same.

I've done this and other tests numerous times here purely for this purpose, there is no possibility of me having "forgotten a change in the middle". But I'm a sceptic too: if you think this is impossible and I'm lying, I don't blame you ;)


In reply to Re: sort != sort by halfcountplus
in thread sort != sort by halfcountplus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.