engine/partitions: add sorting and partitioning by free resources