in reply to Re: Pseudo-hash intrusion...
in thread Pseudo-hash intrusion...

This is still broken.
Inside the sort {}, $a will be one of the list inside $foo, and $b another, so that's how you get the
No such pseudo-hash field "HASH(0x10a57c)" at ./listref line 22.
error, because you have coerced the $foo->{$a} to a pseudo-hash reference when it is really an array reference. The error occurs because If $foo were really a pseudo-hash, it should have a hash as the first element, (which it does) which contains a field to match $a which $foo doesn't.

Within the sort command, $a is already dereferenced, so you must use my @bar = sort {$a->{blah} cmp $b->{blah} } @$foo; Where the names of the fields being compared are the same ('blah' in this case).

my $foo = [ {blah=>5,d=>1}, {blah=>4,d=>2}, {blah=>3,d=>3}, {blah=>2,d=>4}, {blah=>1,d=>5}]; my @bar = sort {$a->{blah} cmp $b->{blah} } @$foo; print join(',',map {$_->{blah}} @bar), $/;
worked for me.

P.S. If this had been an array of arrays, the message is more clear :

my $foo = [ [5,1], [4,2], [3,3], [2,4], [1,5]]; my @bar = sort {$foo->{$a} cmp $foo->{$a} } @$foo; # should be my @bar = sort {$a[0] cmp $b[0]} @$foo;
generates Can't coerce array into hash at ./listref line 33. which is a bit more useful.
--
Brovnik