This reordering-by-conditionals is neat :)  I was thinking lookup table but this is probably better.