halfcountplus,
Here's my two cents. Please consider the following:
- The various sort functions are well-known and I doubt the built-in sort has a new bug.
- Even if the built-in sort is somehow broken, you said you used a couple of other sorts, as well, and I doubt they all broke at once.
- When you feed sort a block, as below,
@Notes = sort { $b->{terms} <=> $a->{terms} } @Notes;
you're comparing number to number (<=>), or text to text (cmp). It returns a -1, 0, or 1. Constructions like the one above are VERY common and work in the general case. You've made an assumption that @Notes is not being assigned to, but if the comparison operators are working, and the sort functions are working, and the assign-to operator is working, then the only thing left is to look at what's actually being compared.
- Which, I hasten to point out, is the one thing we haven't seen yet except as a small excerpt of dumped hashes. We can't duplicate all your code because we don't have all your modules or your databases, and all you are showing us is your code and part of your databases. Please use Data::Dumper or YAML or whatever you like and Dump the the actual structure of @Notes and post at least a subset. Maybe here:
foreach my $l (@lines) {
my $pns = PNSearch->new($MUH, $l->[0]-$cur, $l->[1], $file);
push @Notes, $pns if ($pns);
$cur = $l->[0];
}
close($MUH);
}
use Data::Dumper;
open DUMP, ">somefile.txt" or die $!;
Dumper \@Notes;
close DUMP;
- No one has called you a liar, and it doesn't have to be a bug in your code (which you said you updated, by the by!!!), but obviously something isn't working and that's why people keep asking to see what's actually in @Notes, rather than hear your assurances about it.
Sincerely,
--marmot