in reply to knapsack problem solved by regex
On a hunch I changed:
for ( keys %items ) {
To:
for ( sort { $items{ $b }{ v } <=> $items{ $a }{ v } } keys %items ) {
Which produced a nice speed-up compared to the default hash order.
Note that the converse of:
for ( sort { $items{ $a }{ v } <=> $items{ $b }{ v } } keys %items ) {
Was a lot slower than the default hash order.
|
---|