sort history by createdAt