Updated Sorter to allow transforming allocated resources.

Review: https://reviews.apache.org/r/29083
Updated Allocator to allow transforming allocated resources.

Review: https://reviews.apache.org/r/29084