my @sorted = sort { ($a->[0]-$a->[1])**2 <=> ($b->[0]-$b->[1])**2 } @Connections;