Plate order algorithm.

Missing one key function that I can't quite tease out of my head.