engine/partitions: add sorting and partitioning by free resources

Still work to do, but taking it one step at a time
Seems like overkill to define this as a type