Changed getPosts() to sort posts on the server side.