engine/partitions: add sorting and partitioning by free resources

Still work to do, but taking it one step at a time
I don't actually like either of them, just struggling to come up with something better right now