+ elsif ($get{order} eq 'build') {
+ my %unittime = map { ($_->{name} => $_->{warp} // $_->{build}) } @rows;
+ $unittime{Templar} = $unittime{'High Templar'};
+ $_->{order} = (
+ ($_->{warp} // $_->{build})
+ + ($_->{gas}*1.5 + $_->{min} + $_->{pop}/8)/1024
+ + ($_->{base} ? ($unittime{$_->{base}->[0]} // 100) + 1 : 0)
+ ) for @rows;
+ }
+ 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;