Proper sorting of entities.