Say I want sort a hash of arrays (%hash) by looking up the comparisons in another hash (%comparator):
I thought the following would work, but it didn’t.
for ($bin_ix=1; $bin_ix<scalar(keys(%cluster_bins)); $bin_ix++) {
$hash{$bin_ix} = sort {$comparator{$a} <=> $comparator{$b} $hash{$bin_ix}};
}
It complains with: Missing operator before %hash. What am I missing?
Actually, it says
It’s complaining about your misplaced
}, but there’s a second problem:$hash{$bin_ix}is merely a reference to the array, not an array. You want