added sort function to sort posts by timestamp