Pennsylvania Fair District Rules

In a decision handed down on January 22, 2018 by the Pennsylvania Supreme Court, they decreed that gerrymandered districts shall be thrown out and replaced such that (emphasis mine):
I stared at this paragraph for a boggled minute because the English clauses aren't clearly laid out in a prioritized order. Rationalizing it combined with what I know of redistricting law, I think the priority has to work out to be:

  1. contiguous
  2. equal population
  3. whole towns
  4. compact
If that is a complete statement of what the Pennsylvania courts want out of a district map, it's relatively simple. I clearly need to get hacking on the municipality-preserving version of my compact district solver.