fixed history sorting