my @order = sort {
$Costs[$a]+$Trims[$a]*$Costs[$b] <=> $Costs[$b]+$Trims[$b]*$Costs[
+$a]
} 0..$#Costs;
I'm pretty sure that this is the optimal solution, but I'm too lazy to write down the complete mathematical proof.
The basic idea is that the terms represent the general cost difference of swapping the first and the second filter¹!
So by sorting you get a solution which can't be improved by a pairwise swapping and any permutation can be represented by a sequence of pairwise swaps.
¹) see restructured formula for c in Re^2: Evolving a faster filter? (combinatorics) and you will notice that these are the first elements and the rest is fix.
UPDATE:
basic transformations lead to a simpler solution:
my @order = sort {
$Costs[$a]/(1$Trims[$a]) <=> $Costs[$b]/(1$Trims[$b])
} 0..$#Costs;
which can be precalculated to save calculation time
my @order = sort {
$weight[$a] <=> $weight[$b]
} 0..$#Costs;
(the edge case of a division by zero must be handled as practically infinity)
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, 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, 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: 
 &   & 
 <   < 
 >   > 
 [   [ 
 ]   ] 
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.

