Implement sort functions on entities