added base sorting code to post controller