+ elsif ($get{order} eq 'size') {
+ $_->{order} = (
+ $_->{pop}*16 + ($_->{size} // $_->{suit}) + $_->{cargo}/8
+ + $_->{hp}/512 + $_->{min}/8192
+ ) for @rows;
+ }
+ elsif ($get{order} eq 'hp') {
+ $_->{order} = (
+ $_->{hp}*1.01 + $_->{armor} + $_->{shield} + $_->{size}/1024,
+ ) for @rows;
+ }
+ elsif ($get{order} eq 'attack') {
+ $_->{order} = $_->{hp} / 16384 + max(
+ map {
+ ($_->{dps} ? $_->{dps}->[-1] :
+ ($_->{damage} + $_->{upgrade} * 3)
+ * ($_->{count} // 1) / ($_->{cooldown} // 1)
+ )
+ * ($_->{splash} ? 1.01 : 1)
+ * ($_->{type} eq 'implosive' ? .96 : 1)
+ * ($_->{type} eq 'explosive' ? .98 : 1)
+ } @{ $_->{attack} }
+ ) for @rows;
+ }
+ elsif ($get{order} eq 'speed') {
+ $_->{order} = (
+ ($_->{upgraded}->{speed} // $_->{speed}*1.01)
+ + $_->{sight}/1024 + $_->{detect}/2048
+ ) for @rows;
+ }
+ @rows = sort {$a->{order} <=> $b->{order}} @rows if exists $rows[0]->{order};